diff options
author | Jamie Heppenstall <jamie.heppenstall@mongodb.com> | 2019-06-07 16:21:05 -0400 |
---|---|---|
committer | Jamie Heppenstall <jamie.heppenstall@mongodb.com> | 2019-06-07 16:24:09 -0400 |
commit | 06bf03568dc44fd53485fcf3a955c7faa8252fe7 (patch) | |
tree | 2f8122030e89a460d69516a1aec93f693df36af1 | |
parent | c75dce32fa936f4e2b4a89a566007d4404a232dc (diff) | |
download | mongo-06bf03568dc44fd53485fcf3a955c7faa8252fe7.tar.gz |
SERVER-41091 Check ShardingState::enabled before calling ShardingState::shardId in makeNoopWriteIfNeeded
-rw-r--r-- | src/mongo/db/read_concern_mongod.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/mongo/db/read_concern_mongod.cpp b/src/mongo/db/read_concern_mongod.cpp index 65b27493c33..e362702fb2e 100644 --- a/src/mongo/db/read_concern_mongod.cpp +++ b/src/mongo/db/read_concern_mongod.cpp @@ -136,6 +136,12 @@ Status makeNoopWriteIfNeeded(OperationContext* opCtx, LogicalTime clusterTime) { } bool isConfig = (serverGlobalParams.clusterRole == ClusterRole::ConfigServer); + + if (!isConfig && !ShardingState::get(opCtx)->enabled()) { + return {ErrorCodes::ShardingStateNotInitialized, + "Failed noop write because sharding state has not been initialized"}; + } + auto myShard = isConfig ? Grid::get(opCtx)->shardRegistry()->getConfigShard() : Grid::get(opCtx)->shardRegistry()->getShard( opCtx, ShardingState::get(opCtx)->shardId()); |