diff options
-rw-r--r-- | src/mongo/db/mongod_main.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/s/sharding_initialization_mongod.cpp | 5 | ||||
-rw-r--r-- | src/mongo/s/client/shard_registry.cpp | 14 | ||||
-rw-r--r-- | src/mongo/s/client/shard_registry.h | 6 | ||||
-rw-r--r-- | src/mongo/s/mongos_main.cpp | 5 | ||||
-rw-r--r-- | src/mongo/s/sharding_initialization.cpp | 19 | ||||
-rw-r--r-- | src/mongo/s/sharding_initialization.h | 4 |
7 files changed, 14 insertions, 44 deletions
diff --git a/src/mongo/db/mongod_main.cpp b/src/mongo/db/mongod_main.cpp index 5b6f0b88d1c..6b4ba9d46bd 100644 --- a/src/mongo/db/mongod_main.cpp +++ b/src/mongo/db/mongod_main.cpp @@ -625,11 +625,10 @@ ExitCode _initAndListen(ServiceContext* serviceContext, int listenPort) { auto shardingInitialized = ShardingInitializationMongoD::get(startupOpCtx.get()) ->initializeShardingAwarenessIfNeeded(startupOpCtx.get()); if (shardingInitialized) { - auto status = waitForShardRegistryReload(startupOpCtx.get()); + auto status = loadGlobalSettingsFromConfigServer(startupOpCtx.get()); if (!status.isOK()) { LOGV2(20545, - "Error loading shard registry at startup {error}", - "Error loading shard registry at startup", + "Error loading global settings from config server at startup", "error"_attr = redact(status)); } } diff --git a/src/mongo/db/s/sharding_initialization_mongod.cpp b/src/mongo/db/s/sharding_initialization_mongod.cpp index 9d423f65057..ff2b685cb93 100644 --- a/src/mongo/db/s/sharding_initialization_mongod.cpp +++ b/src/mongo/db/s/sharding_initialization_mongod.cpp @@ -495,11 +495,10 @@ void ShardingInitializationMongoD::onInitialDataAvailable(OperationContext* opCt // This function may take the global lock. auto shardingInitialized = initializeShardingAwarenessIfNeeded(opCtx); if (shardingInitialized) { - auto status = waitForShardRegistryReload(opCtx); + auto status = loadGlobalSettingsFromConfigServer(opCtx); if (!status.isOK()) { LOGV2(6460100, - "Error loading shard registry at startup {error}", - "Error loading shard registry at startup", + "Error loading global settings from config server at startup", "error"_attr = redact(status)); } } diff --git a/src/mongo/s/client/shard_registry.cpp b/src/mongo/s/client/shard_registry.cpp index 6070f3ea82d..a2a50cf5b20 100644 --- a/src/mongo/s/client/shard_registry.cpp +++ b/src/mongo/s/client/shard_registry.cpp @@ -413,20 +413,6 @@ std::unique_ptr<Shard> ShardRegistry::createConnection(const ConnectionString& c return _shardFactory->createUniqueShard(ShardId("<unnamed>"), connStr); } -bool ShardRegistry::isUp() { - if (_isUp.load()) - return true; - - // Before the first lookup is completed, the latest cached value is either empty or it is - // associated to the default constructed time - const auto latestCached = _cache->peekLatestCached(_kSingleton); - if (latestCached && latestCached.getTime() != Time()) { - _isUp.store(true); - return true; - } - return false; -} - void ShardRegistry::toBSON(BSONObjBuilder* result) const { BSONObjBuilder map; BSONObjBuilder hosts; diff --git a/src/mongo/s/client/shard_registry.h b/src/mongo/s/client/shard_registry.h index 0a3b5d3bc09..d606a3c0976 100644 --- a/src/mongo/s/client/shard_registry.h +++ b/src/mongo/s/client/shard_registry.h @@ -271,12 +271,6 @@ public: */ std::unique_ptr<Shard> createConnection(const ConnectionString& connStr) const; - /** - * The ShardRegistry is "up" once a successful lookup from the config servers has been - * completed. - */ - bool isUp(); - void toBSON(BSONObjBuilder* result) const; /** diff --git a/src/mongo/s/mongos_main.cpp b/src/mongo/s/mongos_main.cpp index 55a705eb346..81869a5d08a 100644 --- a/src/mongo/s/mongos_main.cpp +++ b/src/mongo/s/mongos_main.cpp @@ -158,9 +158,6 @@ Status waitForSigningKeys(OperationContext* opCtx) { auto const shardRegistry = Grid::get(opCtx)->shardRegistry(); while (true) { - // This should be true when shard registry is up - invariant(shardRegistry->isUp()); - auto configCS = shardRegistry->getConfigServerConnectionString(); auto rsm = ReplicaSetMonitor::get(configCS.getSetName()); // mongod will set minWireVersion == maxWireVersion for hello requests from @@ -443,7 +440,7 @@ Status initializeSharding(OperationContext* opCtx) { return status; } - status = waitForShardRegistryReload(opCtx); + status = loadGlobalSettingsFromConfigServer(opCtx); if (!status.isOK()) { return status; } diff --git a/src/mongo/s/sharding_initialization.cpp b/src/mongo/s/sharding_initialization.cpp index 94ee8465ad1..b526895db1e 100644 --- a/src/mongo/s/sharding_initialization.cpp +++ b/src/mongo/s/sharding_initialization.cpp @@ -220,7 +220,7 @@ void loadCWWCFromConfigServerForReplication(OperationContext* opCtx) { repl::ReplicationCoordinator::get(opCtx)->recordIfCWWCIsSetOnConfigServerOnStartup(opCtx); } -Status waitForShardRegistryReload(OperationContext* opCtx) { +Status loadGlobalSettingsFromConfigServer(OperationContext* opCtx) { if (serverGlobalParams.clusterRole == ClusterRole::ConfigServer) { return Status::OK(); } @@ -236,24 +236,19 @@ Status waitForShardRegistryReload(OperationContext* opCtx) { opCtx, repl::ReadConcernLevel::kMajorityReadConcern)); // Assert will be raised on failure to talk to config server. loadCWWCFromConfigServerForReplication(opCtx); - if (Grid::get(opCtx)->shardRegistry()->isUp()) { - return Status::OK(); - } - sleepFor(kRetryInterval); - continue; + return Status::OK(); } catch (const DBException& ex) { Status status = ex.toStatus(); - LOGV2_WARNING( - 23834, - "Error {error} initializing sharding state, sleeping for 2 seconds and retrying", - "Error initializing sharding state, sleeping for 2 seconds and retrying", - "error"_attr = status); + LOGV2_WARNING(23834, + "Error loading global settings from config server. Sleeping for 2 " + "seconds and retrying", + "error"_attr = status); sleepFor(kRetryInterval); continue; } } - return {ErrorCodes::ShutdownInProgress, "aborting shard loading attempt"}; + return {ErrorCodes::ShutdownInProgress, "aborted loading global settings from config server"}; } void preCacheMongosRoutingInfo(OperationContext* opCtx) { diff --git a/src/mongo/s/sharding_initialization.h b/src/mongo/s/sharding_initialization.h index 2dbc3ae470b..1d35fc601d2 100644 --- a/src/mongo/s/sharding_initialization.h +++ b/src/mongo/s/sharding_initialization.h @@ -72,10 +72,10 @@ Status initializeGlobalShardingState(OperationContext* opCtx, boost::optional<size_t> taskExecutorPoolSize); /** - * Loads cluster ID and waits for the reload of the Shard Registry. + * Loads global settings from config server such as cluster ID and default write concern. */ -Status waitForShardRegistryReload(OperationContext* opCtx); +Status loadGlobalSettingsFromConfigServer(OperationContext* opCtx); /** * Pre-caches mongod routing info for the calling process. |