summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Fuschetto <antonio.fuschetto@mongodb.com>2022-02-11 20:32:06 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-11 21:32:52 +0000
commit64c2b3d25ba7a50f68e206f5cb05f26d3c3b34fc (patch)
tree68d8e5694b11eb5517827c0af30996ed297083d3
parent070e01f9cd528b7cb8d1933a52612e3961a19376 (diff)
downloadmongo-64c2b3d25ba7a50f68e206f5cb05f26d3c3b34fc.tar.gz
SERVER-62036 Failures in preCacheMongosRoutingInfo() will cause mongos to fail startup
-rw-r--r--src/mongo/s/mongos_main.cpp9
-rw-r--r--src/mongo/s/sharding_initialization.cpp12
-rw-r--r--src/mongo/s/sharding_initialization.h2
3 files changed, 14 insertions, 9 deletions
diff --git a/src/mongo/s/mongos_main.cpp b/src/mongo/s/mongos_main.cpp
index 9fc9eb9b092..7ed6e3d4315 100644
--- a/src/mongo/s/mongos_main.cpp
+++ b/src/mongo/s/mongos_main.cpp
@@ -445,9 +445,12 @@ Status initializeSharding(OperationContext* opCtx) {
return status;
}
- status = preCacheMongosRoutingInfo(opCtx);
- if (!status.isOK()) {
- return status;
+ // Loading of routing information may fail. Since this is just an optimization (warmup), any
+ // failure must not prevent mongos from starting.
+ try {
+ preCacheMongosRoutingInfo(opCtx);
+ } catch (const DBException& ex) {
+ LOGV2_WARNING(6203601, "Failed to warmup routing information", "error"_attr = redact(ex));
}
status = preWarmConnectionPool(opCtx);
diff --git a/src/mongo/s/sharding_initialization.cpp b/src/mongo/s/sharding_initialization.cpp
index 5d0281dad7d..dae29a19a6c 100644
--- a/src/mongo/s/sharding_initialization.cpp
+++ b/src/mongo/s/sharding_initialization.cpp
@@ -253,13 +253,13 @@ Status waitForShardRegistryReload(OperationContext* opCtx) {
return {ErrorCodes::ShutdownInProgress, "aborting shard loading attempt"};
}
-Status preCacheMongosRoutingInfo(OperationContext* opCtx) {
+void preCacheMongosRoutingInfo(OperationContext* opCtx) {
if (!gLoadRoutingTableOnStartup) {
- return Status::OK();
+ return;
}
if (serverGlobalParams.clusterRole == ClusterRole::ConfigServer) {
- return Status::OK();
+ return;
}
auto grid = Grid::get(opCtx);
@@ -272,11 +272,13 @@ Status preCacheMongosRoutingInfo(OperationContext* opCtx) {
opCtx, db.getName(), repl::ReadConcernLevel::kMajorityReadConcern)) {
auto resp = catalogCache->getShardedCollectionRoutingInfoWithRefresh(opCtx, coll);
if (!resp.isOK()) {
- return resp.getStatus();
+ LOGV2_WARNING(6203600,
+ "Failed to warmup collection routing information",
+ "namespace"_attr = coll,
+ "error"_attr = redact(resp.getStatus()));
}
}
}
- return Status::OK();
}
Status preWarmConnectionPool(OperationContext* opCtx) {
diff --git a/src/mongo/s/sharding_initialization.h b/src/mongo/s/sharding_initialization.h
index ba33d171f7d..2dbc3ae470b 100644
--- a/src/mongo/s/sharding_initialization.h
+++ b/src/mongo/s/sharding_initialization.h
@@ -81,7 +81,7 @@ Status waitForShardRegistryReload(OperationContext* opCtx);
* Pre-caches mongod routing info for the calling process.
*/
-Status preCacheMongosRoutingInfo(OperationContext* opCtx);
+void preCacheMongosRoutingInfo(OperationContext* opCtx);
/**
* Warms up connections to shards with best effort strategy.