[SERVER-54891] Lock-free read operations must not call RecoveryUnit::setTimestampReadSource() outside of the AutoGetCollectionForReadLockFree collection helper Created: 02/Mar/21  Updated: 29/Oct/23  Resolved: 01/Apr/21

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

Type: Bug Priority: Major - P3
Reporter: Dianna Hohensee (Inactive) Assignee: Henrik Edin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Execution Team 2021-04-05
Participants:

 Description   

TLDR; we need to investigate whether we have RecoveryUnit::setTimestampReadSource() calls outside of the AutoGet* helpers in lock-free read operation codepaths. These could invariant if timed with a repl state change.

--------------------------------------------------------------------
Context:

I found a bug described in SERVER-54889 wherein the AutoGetCollectionForReadLockFree is misbehaving regarding the use of RecoveryUnit::setTimestampReadSource() establishing a read source.

---------------------------------------------------------------------
Example concern:

Perusing the codebase, I see that the getMore cmd can call RecoveryUnit::setTimestampReadSource() after instantiating an AutoGetCollectionForReadLockFree instance. RecoveryUnit::setTimestampReadSource() invariants that no snapshot is open before it starts. Therefore, this code is susceptible to invariant'ing and crashing given perfect timing of a repl state change causing the explicit RecoveryUnit::setTimestampReadSource(majority) call to differ from the AutoGetCollectionForReadLockFree read source selection.

Another possibility is that the code described can never hit an invariant because the read source selection is always the same, in which case the explicit RecoveryUnit::setTimestampReadSource() call should be removed.



 Comments   
Comment by Githook User [ 01/Apr/21 ]

Author:

{'name': 'Henrik Edin', 'email': 'henrik.edin@mongodb.com', 'username': 'henrikedin'}

Message: SERVER-54891 Set read source before AutoGetCollectionForRead so we don't abandon a snapshot setup by the AutoColl.
Branch: master
https://github.com/mongodb/mongo/commit/629c2b8743ad9876a96d13d35c3d1e08df73b8cf

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