summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierlauro Sciarelli <pierlauro.sciarelli@mongodb.com>2021-12-14 11:23:00 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-12-14 12:38:18 +0000
commitd8daca95a6b1d554cc87b5321b6475d4dd2888bf (patch)
tree3b14fcda105e6149653cf1916e81f637626c9f08
parent83d6ea236b8177a21a08ba6acfc98e43a32f883c (diff)
downloadmongo-d8daca95a6b1d554cc87b5321b6475d4dd2888bf.tar.gz
SERVER-61214 Ensure having the latest known entry of the catalog cache when creating config.system.sessions
-rw-r--r--src/mongo/db/s/sessions_collection_config_server.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/mongo/db/s/sessions_collection_config_server.cpp b/src/mongo/db/s/sessions_collection_config_server.cpp
index a9c7788ec92..28f1ce20e84 100644
--- a/src/mongo/db/s/sessions_collection_config_server.cpp
+++ b/src/mongo/db/s/sessions_collection_config_server.cpp
@@ -87,14 +87,25 @@ void SessionsCollectionConfigServer::_generateIndexesIfNeeded(OperationContext*
nss,
"SessionsCollectionConfigServer::_generateIndexesIfNeeded",
[&] {
- auto routingInfo = uassertStatusOK(
- Grid::get(opCtx)->catalogCache()->getCollectionRoutingInfo(opCtx, nss));
+ const ChunkManager cm = [&]() {
+ // (SERVER-61214) wait for the catalog cache to acknowledge that the sessions
+ // collection is sharded in order to be sure to get a valid routing table
+ while (true) {
+ auto cm = uassertStatusOK(
+ Grid::get(opCtx)->catalogCache()->getCollectionRoutingInfoWithRefresh(opCtx,
+ nss));
+
+ if (cm.isSharded()) {
+ return cm;
+ }
+ }
+ }();
scatterGatherVersionedTargetByRoutingTable(
opCtx,
nss.db(),
nss,
- routingInfo,
+ cm,
SessionsCollection::generateCreateIndexesCmd(),
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
Shard::RetryPolicy::kNoRetry,