diff options
Diffstat (limited to 'src/mongo/db/s')
5 files changed, 11 insertions, 18 deletions
diff --git a/src/mongo/db/s/balancer/balancer.cpp b/src/mongo/db/s/balancer/balancer.cpp index be50d5c8f60..52699c273a2 100644 --- a/src/mongo/db/s/balancer/balancer.cpp +++ b/src/mongo/db/s/balancer/balancer.cpp @@ -467,7 +467,7 @@ bool Balancer::_checkOIDs(OperationContext* opCtx) { auto shardingContext = Grid::get(opCtx); vector<ShardId> all; - shardingContext->shardRegistry()->getAllShardIds(&all); + shardingContext->shardRegistry()->getAllShardIdsNoReload(&all); // map of OID machine ID => shardId map<int, ShardId> oids; diff --git a/src/mongo/db/s/config/configsvr_drop_database_command.cpp b/src/mongo/db/s/config/configsvr_drop_database_command.cpp index fe4b658dca2..7d4cfcbd5a4 100644 --- a/src/mongo/db/s/config/configsvr_drop_database_command.cpp +++ b/src/mongo/db/s/config/configsvr_drop_database_command.cpp @@ -154,7 +154,7 @@ public: // Drop the database from each of the remaining shards. { std::vector<ShardId> allShardIds; - Grid::get(opCtx)->shardRegistry()->getAllShardIds(&allShardIds); + Grid::get(opCtx)->shardRegistry()->getAllShardIdsNoReload(&allShardIds); for (const ShardId& shardId : allShardIds) { _dropDatabaseFromShard(opCtx, shardId, dbname); diff --git a/src/mongo/db/s/config/configsvr_shard_collection_command.cpp b/src/mongo/db/s/config/configsvr_shard_collection_command.cpp index b88978aecd7..6732c7e9678 100644 --- a/src/mongo/db/s/config/configsvr_shard_collection_command.cpp +++ b/src/mongo/db/s/config/configsvr_shard_collection_command.cpp @@ -745,6 +745,7 @@ public: auto const catalogManager = ShardingCatalogManager::get(opCtx); auto const catalogCache = Grid::get(opCtx)->catalogCache(); auto const catalogClient = Grid::get(opCtx)->catalogClient(); + auto shardRegistry = Grid::get(opCtx)->shardRegistry(); // Make the distlocks boost::optional so that they can be released by being reset below. boost::optional<DistLockManager::ScopedDistLock> dbDistLock( @@ -773,7 +774,7 @@ public: ShardKeyPattern shardKeyPattern(proposedKey); std::vector<ShardId> shardIds; - Grid::get(opCtx)->shardRegistry()->getAllShardIds(&shardIds); + shardRegistry->getAllShardIds(opCtx, &shardIds); const int numShards = shardIds.size(); uassert(ErrorCodes::IllegalOperation, @@ -788,8 +789,7 @@ public: "only special collections in the config db may be sharded", nss.ns() == SessionsCollection::kSessionsFullNS || getTestCommandsEnabled()); - auto configShard = uassertStatusOK( - Grid::get(opCtx)->shardRegistry()->getShard(opCtx, dbType.getPrimary())); + auto configShard = uassertStatusOK(shardRegistry->getShard(opCtx, dbType.getPrimary())); ScopedDbConnection configConn(configShard->getConnString()); ON_BLOCK_EXIT([&configConn] { configConn.done(); }); @@ -810,8 +810,7 @@ public: } }(); - auto primaryShard = - uassertStatusOK(Grid::get(opCtx)->shardRegistry()->getShard(opCtx, primaryShardId)); + auto primaryShard = uassertStatusOK(shardRegistry->getShard(opCtx, primaryShardId)); ScopedDbConnection conn(primaryShard->getConnString()); ON_BLOCK_EXIT([&conn] { conn.done(); }); diff --git a/src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp index 511b7bdfae9..574a3e5a9c1 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp @@ -191,7 +191,7 @@ ChunkVersion ShardingCatalogManager::_createFirstChunks(OperationContext* opCtx, [&opCtx, primaryShardId, &shardIds, primaryDraining]() { if (primaryDraining) { vector<ShardId> allShardIds; - Grid::get(opCtx)->shardRegistry()->getAllShardIds(&allShardIds); + Grid::get(opCtx)->shardRegistry()->getAllShardIdsNoReload(&allShardIds); auto dbShardId = allShardIds[0]; if (allShardIds[0] == primaryShardId && allShardIds.size() > 1) { @@ -238,7 +238,7 @@ ChunkVersion ShardingCatalogManager::_createFirstChunks(OperationContext* opCtx, // If docs already exist for the collection, must use primary shard, // otherwise defer to passed-in distribution option. if (numObjects == 0 && distributeInitialChunks) { - Grid::get(opCtx)->shardRegistry()->getAllShardIds(&shardIds); + Grid::get(opCtx)->shardRegistry()->getAllShardIdsNoReload(&shardIds); if (primaryDraining && shardIds.size() > 1) { shardIds.erase(std::remove(shardIds.begin(), shardIds.end(), primaryShardId), shardIds.end()); @@ -259,7 +259,7 @@ ChunkVersion ShardingCatalogManager::_createFirstChunks(OperationContext* opCtx, } if (distributeInitialChunks) { - Grid::get(opCtx)->shardRegistry()->getAllShardIds(&shardIds); + Grid::get(opCtx)->shardRegistry()->getAllShardIdsNoReload(&shardIds); if (primaryDraining) { shardIds.erase(std::remove(shardIds.begin(), shardIds.end(), primaryShardId), shardIds.end()); @@ -655,7 +655,6 @@ void ShardingCatalogManager::createCollection(OperationContext* opCtx, createCmdBuilder.append("create", ns.coll()); collOptions.appendBSON(&createCmdBuilder); createCmdBuilder.append(kWriteConcernField, opCtx->getWriteConcern().toBSON()); - auto swResponse = primaryShard->runCommandWithFixedRetryAttempts( opCtx, ReadPreferenceSetting{ReadPreference::PrimaryOnly}, diff --git a/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp index 34263b7cb31..2ee60c2011d 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp @@ -887,14 +887,9 @@ StatusWith<ShardId> ShardingCatalogManager::_selectShardForNewDatabase( OperationContext* opCtx, ShardRegistry* shardRegistry) { std::vector<ShardId> allShardIds; - shardRegistry->getAllShardIds(&allShardIds); + shardRegistry->getAllShardIds(opCtx, &allShardIds); if (allShardIds.empty()) { - shardRegistry->reload(opCtx); - shardRegistry->getAllShardIds(&allShardIds); - - if (allShardIds.empty()) { - return Status(ErrorCodes::ShardNotFound, "No shards found"); - } + return Status(ErrorCodes::ShardNotFound, "No shards found"); } ShardId candidateShardId = allShardIds[0]; |