[SERVER-61459] ShardingCatalogManager::assignKeyRangeToZone() reads stale version of CollectionType while running locally on config server primary Created: 12/Nov/21  Updated: 29/Oct/23  Resolved: 18/Nov/21

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 5.1.0, 5.0.4
Fix Version/s: 5.2.0, 5.1.2, 5.0.6

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:
Backports
Depends
is depended on by SERVER-59831 WTUniqueIndex::_insert expects second... Closed
Problem/Incident
is caused by SERVER-57566 Implement sharding admin commands beh... Closed
Related
related to SERVER-61458 Calling RSLocalClient::queryOnce(kMaj... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v5.1, v5.0
Sprint: Execution Team 2021-11-29
Participants:
Linked BF Score: 152

 Description   

The changes from 21f26eb as part of SERVER-57566 added a usage of RSLocalClient::queryOnce(kMajorityReadConcern) when RSLocalClient::queryOnce(kLocalReadConcern) was intended. ShardingCatalogClient::getCollection() defaults to use kMajorityReadConcern when the repl::ReadConcernLevel is omitted.

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.

try {
    const auto& coll = Grid::get(opCtx)->catalogClient()->getCollection(opCtx, nss);
    const auto& timeseriesField = coll.getTimeseriesFields();
    if (timeseriesField) {
        uassertStatusOK(
            checkForTimeseriesTimeFieldKeyRange(actualRange, timeseriesField->getTimeField()));
    }
} catch (const ExceptionFor<ErrorCodes::NamespaceNotFound>&) {
    // collection doesn't exist or not sharded, skip range check for time-series collection.
}



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

Author:

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

Message: SERVER-61459 Use local read concern to get CollectionType when running assignKeyRangeToZone() on config server primary

(cherry picked from commit 1d7213c3cbc6df1fed6de011dc18f23ced59bd25)
Branch: v5.0
https://github.com/mongodb/mongo/commit/e2aa79b904fe237c04e71b23fd1ce77726b8c0ba

Comment by Githook User [ 23/Nov/21 ]

Author:

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

Message: SERVER-61459 Use local read concern to get CollectionType when running assignKeyRangeToZone() on config server primary

(cherry picked from commit 1d7213c3cbc6df1fed6de011dc18f23ced59bd25)
Branch: v5.1
https://github.com/mongodb/mongo/commit/6ec4d3ccaedbcfee4585f97f3646099d171cf659

Comment by Githook User [ 18/Nov/21 ]

Author:

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

Message: SERVER-61459 Use local read concern to get CollectionType when running assignKeyRangeToZone() on config server primary
Branch: master
https://github.com/mongodb/mongo/commit/1d7213c3cbc6df1fed6de011dc18f23ced59bd25

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