[SERVER-61458] Calling RSLocalClient::queryOnce(kMajorityReadConcern) causes subsequent local writes in same OperationContext to also read stale data Created: 12/Nov/21  Updated: 29/Oct/23  Resolved: 25/Nov/21

Status: Closed
Project: Core Server
Component/s: Internal Client
Affects Version/s: 4.0.0, 4.2.0, 4.4.0, 5.0.0, 5.1.0
Fix Version/s: 5.2.0

Type: Bug Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Yuhong Zhang
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-59831 WTUniqueIndex::_insert expects second... Closed
is related to SERVER-61459 ShardingCatalogManager::assignKeyRang... Closed
is related to SERVER-57566 Implement sharding admin commands beh... Closed
is related to SERVER-61704 Investigate the usage of abandonSnaps... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Execution Team 2021-11-29
Participants:
Linked BF Score: 152

 Description   

RSLocalClient::queryOnce(kMajorityReadConcern) will modify the ReadSource for the RecoveryUnit to be kMajorityCommitted. It won't restore the original ReadSource upon returning from the function. This issue was discovered during SERVER-59831 because it caused a later write using the same OperationContext to still be using kMajorityCommitted as its ReadSource and for the later write not to see the effects of an earlier write from secondary batch application.

if (readConcernLevel == repl::ReadConcernLevel::kMajorityReadConcern) {
    // Set up operation context with majority read snapshot so correct optime can be retrieved.
    opCtx->recoveryUnit()->setTimestampReadSource(RecoveryUnit::ReadSource::kMajorityCommitted);
    ...
}

My thought here would be to introduce a new RAII type to enable the ReadSource to be temporarily overridden and to use it in RSLocalClient::queryOnce().



 Comments   
Comment by Githook User [ 24/Nov/21 ]

Author:

{'name': 'Yuhong Zhang', 'email': 'danielzhangyh@gmail.com', 'username': 'YuhongZhang98'}

Message: SERVER-61458 Reset read source after using kMajorityReadConcern in RSLocalClient::queryOnce()
Branch: master
https://github.com/mongodb/mongo/commit/3a7b71e5ff579a56fa1fe4d5d6c4cf3337a0f016

Comment by Yuhong Zhang [ 17/Nov/21 ]

The RAII type ReadSourceScope can be used here.

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