[SERVER-48532] [4.2] IndexBuildInterceptor::areAllWritesApplied may return false despite all records being visibly applied Created: 01/Jun/20  Updated: 29/Oct/23  Resolved: 17/Jun/20

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 4.2.9

Type: Bug Priority: Major - P3
Reporter: Louis Williams Assignee: Gregory Noma
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Execution Team 2020-06-29
Participants:
Linked BF Score: 10

 Description   

Due to a not-well-understood bug in hybrid index builds, we can count (in-memory) more side writes applied than we recorded. This has not caused any data inconsistencies but may cause the server to crash in very rare scenarios.

As of, SERVER-44507, even when the side-writes table is visibly empty, we will return 'false' when writesRecorded does not equal _numApplied such that this invariant fails.

  • If _numApplied, the number of keys read from the side table and written into the index, is less than writesRecorded, the number inserted into the side table, this suggests there are keys not visible in our snapshot. We could complete the index build with inconsistencies. This was addressed by SERVER-44507.
  • If, however, _numApplied is greater than writesRecorded, this suggests we either double-counted or double-applied a key. Double counting would suggest a bug in the code that tracks inserts. These counters are only used for progress reporting and invariants, so I am not concerned about this. Double-inserting could be concerning, but indexes allow key overwrites, so we would never introduce an inconsistency in this case, we would just overwrite a previous key.

I would suggest modifying the logic to only return 'false' if _numApplied is less than numRecorded. This partially reverts to the behavior of SERVER-44507, such that we log a warning, but always return 'true' if these counts differ.



 Comments   
Comment by Githook User [ 17/Jun/20 ]

Author:

{'name': 'Gregory Noma', 'email': 'gregory.noma@gmail.com', 'username': 'gregorynoma'}

Message: SERVER-48532 Return true from IndexBuildInterceptor::areAllWritesApplied() if _numApplied is greater than writesRecorded
Branch: v4.2
https://github.com/mongodb/mongo/commit/3a382a875bd687774ff20d297086398a97298da3

Generated at Thu Feb 08 05:17:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.