diff --git a/jstests/sharding/repro.js b/jstests/sharding/repro.js new file mode 100644 index 00000000000..dcb1ca996ee --- /dev/null +++ b/jstests/sharding/repro.js @@ -0,0 +1,27 @@ +/** + * + */ +(function() { +"use strict"; + +var st = new ShardingTest({ + shards: 1, + config: 1, + mongos: 1 +}); + +const dbName = "test"; +const collName = "foo"; +const ns = dbName + "." + collName; +const db = st.s.getDB(dbName); + +assert.commandWorked(st.s.adminCommand({enableSharding: dbName})); +assert.commandWorked(st.s.adminCommand({shardCollection: ns, key: {_id: 1}})); + +assert.commandFailedWithCode(db.adminCommand({reshardCollection: ns, key: {newKey: 1}, maxTimeMS: 100}), ErrorCodes.MaxTimeMSExpired); + +// Let the resharding finish +sleep(60*1000); + +st.stop(); +})(); diff --git a/src/mongo/db/s/reshard_collection_coordinator.cpp b/src/mongo/db/s/reshard_collection_coordinator.cpp index 452f17fdaf6..f467e0d942d 100644 --- a/src/mongo/db/s/reshard_collection_coordinator.cpp +++ b/src/mongo/db/s/reshard_collection_coordinator.cpp @@ -64,6 +64,8 @@ SemiFuture ReshardCollectionCoordinator::runImpl( configsvrReshardCollection.setZones(_request.getZones()); configsvrReshardCollection.setNumInitialChunks(_request.getNumInitialChunks()); + sleepsecs(1); + auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard(); const auto cmdResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts( opCtx,