0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 01:21:03 +01:00

SERVER-38933 currentOp is not resilient to drop shard

This commit is contained in:
Martin Neupauer 2019-01-10 13:57:28 -05:00
parent 18c4eaee71
commit 08408f7893
3 changed files with 29 additions and 0 deletions

View File

@ -25,6 +25,7 @@ selector:
- jstests/sharding/basic_merge.js
- jstests/sharding/count1.js
- jstests/sharding/count2.js
- jstests/sharding/current_op_with_drop_shard.js
- jstests/sharding/cursor1.js
- jstests/sharding/diffservers1.js
- jstests/sharding/disable_autosplit.js

View File

@ -0,0 +1,25 @@
// Tests that currentOp is resilient to drop shard.
(function() {
'use strict';
const st = new ShardingTest({shards: 2, rs: {nodes: 1}});
// We need the balancer to remove a shard.
st.startBalancer();
const mongosDB = st.s.getDB(jsTestName());
const shardName = st.shard0.shardName;
var res = st.s.adminCommand({removeShard: shardName});
assert.commandWorked(res);
assert.eq('started', res.state);
assert.soon(function() {
res = st.s.adminCommand({removeShard: shardName});
assert.commandWorked(res);
return ('completed' === res.state);
}, "removeShard never completed for shard " + shardName);
assert.commandWorked(mongosDB.currentOp());
st.stop();
})();

View File

@ -441,6 +441,9 @@ MongoSInterface::DispatchShardPipelineResults MongoSInterface::dispatchShardPipe
if (!shardRegistry->reload(opCtx)) {
shardRegistry->reload(opCtx);
}
// Rebuild the set of shards as the shard registry might have changed.
shardIds = getTargetedShards(
opCtx, mustRunOnAll, executionNsRoutingInfo, shardQuery, aggRequest.getCollation());
}
// Explain does not produce a cursor, so instead we scatter-gather commands to the shards.