[SERVER-82396] PreImagesTruncateManager truncate initialization reads at lastApplied can miss inserts Created: 24/Oct/23  Updated: 27/Oct/23  Resolved: 27/Oct/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.2.0-rc0

Type: Bug Priority: Major - P3
Reporter: Haley Connelly Assignee: Haley Connelly
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 EMEA Team 2023-10-30
Participants:
Linked BF Score: 5

 Description   

By default, internal secondary readers read at 'lastApplied'. By reading at 'lastApplied' by default, the tenant's truncate marker initialization can miss a pre-image insert if initialization completes in the middle of oplog batch application on the secondary.

The consequence: If an inserted pre-image has a higher RecordId that the highest RecordId tracked by the truncate markers, the pre-image won't be removed until the next insert.

For example, suppose:

  • The 'lastApplied' timestamp is at TS(5), captured in snapshot0.
  • Truncate marker generation begins, sees 4 documents with nsUUID0 at snapshot0.
  • Secondary oplog batch application inserts a 5th pre-image to nsUUID0 at TS(10), but oplog application is still between batches and lastApplied hasn't been advanced.
    • The insert updates the 'tenantMapEntry', serving as a placeholder until truncate marker generation is complete, with a new set of truncate markers for nsUUID0 that have _lastHighestRecordId encoding TS(10).
  • The 'tenantMapEntry' placeholder truncate markers for nsUUID0 are overwritten because generatedTruncateMarkers also had a set of truncate markers for nsUUID0.
  • Even after abandoning snapshot0, the new snapshot still reads at lastApplied TS(5) because the oplog batch application hasn't completed yet. 
  • Thus, the truncate markers never track the 5th document inserted into the pre-images collection. 
    • If the truncate markers for nsUUID0 don't include the 5th pre-image, the 5th pre-image won't be removed until another pre-image for nsUUID0 is inserted, and updates the _lastHighestRecordId.


 Comments   
Comment by Githook User [ 27/Oct/23 ]

Author:

{'name': 'Haley Connelly', 'email': 'haley.connelly@mongodb.com', 'username': 'haleyConnelly'}

Message: SERVER-82396 Make pre image truncate marker initialization use ReadSource::kNoTimestamp
Branch: master
https://github.com/mongodb/mongo/commit/f95e3a502ca42a94305ab561978fc91a6cc0e97a

Generated at Thu Feb 08 06:49:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.