diff --git a/jstests/sharding/configsvr_metadata_commands_require_majority_write_concern.js b/jstests/sharding/configsvr_metadata_commands_require_majority_write_concern.js index a955f17b0c..d9aed21cdc 100644 --- a/jstests/sharding/configsvr_metadata_commands_require_majority_write_concern.js +++ b/jstests/sharding/configsvr_metadata_commands_require_majority_write_concern.js @@ -129,37 +129,39 @@ var st = new ShardingTest({shards: 1}); - // enableSharding - checkCommandMongos({enableSharding: dbName}, setupFuncs.noop, cleanupFuncs.dropDatabase); - checkCommandConfigSvr( - {_configsvrEnableSharding: dbName}, setupFuncs.noop, cleanupFuncs.dropDatabase); - - // movePrimary - checkCommandMongos({movePrimary: dbName, to: st.shard0.name}, - setupFuncs.createDatabase, - cleanupFuncs.dropDatabase); - checkCommandConfigSvr({_configsvrMovePrimary: dbName, to: st.shard0.name}, - setupFuncs.createDatabase, - cleanupFuncs.dropDatabase); - - // We are using a different name from ns because it was already created in setupFuncs. - checkCommandConfigSvr({_configsvrCreateCollection: dbName + '.bar', options: {}}, - setupFuncs.createDatabase, - cleanupFuncs.dropDatabase); - - // shardCollection - checkCommandMongos( - {shardCollection: ns, key: {_id: 1}}, setupFuncs.enableSharding, cleanupFuncs.dropDatabase); - checkCommandConfigSvr({_configsvrShardCollection: ns, key: {_id: 1}}, - setupFuncs.enableSharding, - cleanupFuncs.dropDatabase); - - // createDatabase - // Don't check createDatabase against mongos: there is no createDatabase command exposed on - // mongos; a database is created implicitly when a collection in it is created. - checkCommandConfigSvr({_configsvrCreateDatabase: dbName, to: st.shard0.name}, - setupFuncs.noop, - cleanupFuncs.dropDatabase); + // // enableSharding + // checkCommandMongos({enableSharding: dbName}, setupFuncs.noop, cleanupFuncs.dropDatabase); + // checkCommandConfigSvr( + // {_configsvrEnableSharding: dbName}, setupFuncs.noop, cleanupFuncs.dropDatabase); + // + // // movePrimary + // checkCommandMongos({movePrimary: dbName, to: st.shard0.name}, + // setupFuncs.createDatabase, + // cleanupFuncs.dropDatabase); + // checkCommandConfigSvr({_configsvrMovePrimary: dbName, to: st.shard0.name}, + // setupFuncs.createDatabase, + // cleanupFuncs.dropDatabase); + // + // // We are using a different name from ns because it was already created in setupFuncs. + // checkCommandConfigSvr({_configsvrCreateCollection: dbName + '.bar', options: {}}, + // setupFuncs.createDatabase, + // cleanupFuncs.dropDatabase); + // + // // shardCollection + // checkCommandMongos( + // {shardCollection: ns, key: {_id: 1}}, setupFuncs.enableSharding, + // cleanupFuncs.dropDatabase); + // checkCommandConfigSvr({_configsvrShardCollection: ns, key: {_id: 1}}, + // setupFuncs.enableSharding, + // cleanupFuncs.dropDatabase); + // + // // createDatabase + // // Don't check createDatabase against mongos: there is no createDatabase command exposed + // on + // // mongos; a database is created implicitly when a collection in it is created. + // checkCommandConfigSvr({_configsvrCreateDatabase: dbName, to: st.shard0.name}, + // setupFuncs.noop, + // cleanupFuncs.dropDatabase); // addShard var newShard = MongoRunner.runMongod({shardsvr: ""}); @@ -170,30 +172,31 @@ setupFuncs.noop, cleanupFuncs.removeShardIfExists); - // removeShard - checkCommandMongos({removeShard: newShardName}, setupFuncs.addShard, cleanupFuncs.noop); - checkCommandConfigSvr( - {_configsvrRemoveShard: newShardName}, setupFuncs.addShard, cleanupFuncs.noop); - - // dropCollection - checkCommandMongos({drop: ns}, setupFuncs.createDatabase, cleanupFuncs.dropDatabase); - checkCommandConfigSvr( - {_configsvrDropCollection: ns}, setupFuncs.createDatabase, cleanupFuncs.dropDatabase); - - // dropDatabase - - // We can't use the checkCommandMongos wrapper because we need a connection to the test - // database. - checkCommand(st.s.getDB(dbName), - {dropDatabase: 1}, - unacceptableWCsForMongos, - acceptableWCsForMongos, - false, - setupFuncs.createDatabase, - cleanupFuncs.dropDatabase); - checkCommandConfigSvr( - {_configsvrDropDatabase: dbName}, setupFuncs.createDatabase, cleanupFuncs.dropDatabase); - + // // removeShard + // checkCommandMongos({removeShard: newShardName}, setupFuncs.addShard, cleanupFuncs.noop); + // checkCommandConfigSvr( + // {_configsvrRemoveShard: newShardName}, setupFuncs.addShard, cleanupFuncs.noop); + // + // // dropCollection + // checkCommandMongos({drop: ns}, setupFuncs.createDatabase, cleanupFuncs.dropDatabase); + // checkCommandConfigSvr( + // {_configsvrDropCollection: ns}, setupFuncs.createDatabase, cleanupFuncs.dropDatabase); + // + // // dropDatabase + // + // // We can't use the checkCommandMongos wrapper because we need a connection to the test + // // database. + // checkCommand(st.s.getDB(dbName), + // {dropDatabase: 1}, + // unacceptableWCsForMongos, + // acceptableWCsForMongos, + // false, + // setupFuncs.createDatabase, + // cleanupFuncs.dropDatabase); + // checkCommandConfigSvr( + // {_configsvrDropDatabase: dbName}, setupFuncs.createDatabase, + // cleanupFuncs.dropDatabase); + // MongoRunner.stopMongos(newShard); st.stop(); })(); 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 688b4f98de..7551201320 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 @@ -831,6 +831,7 @@ StatusWith ShardingCatalogManager::removeShard(OperationCon return ShardDrainingStatus::ONGOING; } + auto t = std::thread([&]() { shardRegistry->reload(opCtx); }); // Draining is done, now finish removing the shard. log() << "going to remove shard: " << name; audit::logRemoveShard(opCtx->getClient(), name); @@ -850,6 +851,7 @@ StatusWith ShardingCatalogManager::removeShard(OperationCon ReplicaSetMonitor::remove(name); shardRegistry->reload(opCtx); + t.join(); // Record finish in changelog Grid::get(opCtx) diff --git a/src/mongo/s/client/shard_registry.cpp b/src/mongo/s/client/shard_registry.cpp index ddc749edcd..429821e669 100644 --- a/src/mongo/s/client/shard_registry.cpp +++ b/src/mongo/s/client/shard_registry.cpp @@ -333,6 +333,7 @@ bool ShardRegistry::reload(OperationContext* opCtx) { auto name = shard->getConnString().getSetName(); ReplicaSetMonitor::remove(name); } + sleepsecs(1); nextReloadState = ReloadState::Idle; // first successful reload means that registry is up