summaryrefslogtreecommitdiff
path: root/src/mongo/db/sessions_collection_sharded.cpp
diff options
context:
space:
mode:
authorBlake Oler <blake.oler@mongodb.com>2018-04-20 11:59:06 -0400
committerBlake Oler <blake.oler@mongodb.com>2018-04-20 12:10:44 -0400
commit60cb34ea7351d25b0eb6bee947d21ada09cf438b (patch)
treeb567e1415b8dd3e2b7270e96600adf3d66b84bef /src/mongo/db/sessions_collection_sharded.cpp
parentc6e3031ef797b9e3c65de9aaf9da812c49a97e5a (diff)
downloadmongo-60cb34ea7351d25b0eb6bee947d21ada09cf438b.tar.gz
SERVER-32677 Prevent sessions periodic refresh from prematurely accessing sharding internals
Diffstat (limited to 'src/mongo/db/sessions_collection_sharded.cpp')
-rw-r--r--src/mongo/db/sessions_collection_sharded.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/mongo/db/sessions_collection_sharded.cpp b/src/mongo/db/sessions_collection_sharded.cpp
index a0142e2a2fd..8873f17be4b 100644
--- a/src/mongo/db/sessions_collection_sharded.cpp
+++ b/src/mongo/db/sessions_collection_sharded.cpp
@@ -56,6 +56,11 @@ BSONObj lsidQuery(const LogicalSessionId& lsid) {
} // namespace
Status SessionsCollectionSharded::_checkCacheForSessionsCollection(OperationContext* opCtx) {
+ // If the sharding state is not yet initialized, fail.
+ if (!Grid::get(opCtx)->isShardingInitialized()) {
+ return {ErrorCodes::ShardingStateNotInitialized, "sharding state is not yet initialized"};
+ }
+
// If the collection doesn't exist, fail. Only the config servers generate it.
auto res = Grid::get(opCtx)->catalogCache()->getShardedCollectionRoutingInfoWithRefresh(
opCtx, NamespaceString(SessionsCollection::kSessionsFullNS.toString()));