summaryrefslogtreecommitdiff
path: root/jstests/sharding/balancing_sessions_collection.js
diff options
context:
space:
mode:
authorCheahuychou Mao <mao.cheahuychou@gmail.com>2020-12-18 20:19:13 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-12-21 15:42:36 +0000
commit03637b5614c1a29983cdac9a1f9ab2d3f7060f15 (patch)
treeaa3a04f05e56c1a3f0f9571a329d3957ffc8bf52 /jstests/sharding/balancing_sessions_collection.js
parentf36403d9057c00586489a8c688f8faaa602f8d2e (diff)
downloadmongo-03637b5614c1a29983cdac9a1f9ab2d3f7060f15.tar.gz
SERVER-53444 Make tests that run removeShard in assert.soon to wait for the state to become completed not error on ShardNotFound
Diffstat (limited to 'jstests/sharding/balancing_sessions_collection.js')
-rw-r--r--jstests/sharding/balancing_sessions_collection.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/jstests/sharding/balancing_sessions_collection.js b/jstests/sharding/balancing_sessions_collection.js
index 416eaa6186d..8313b1ca80d 100644
--- a/jstests/sharding/balancing_sessions_collection.js
+++ b/jstests/sharding/balancing_sessions_collection.js
@@ -51,6 +51,15 @@ function removeShardFromCluster(shardName) {
assert.commandWorked(st.s.adminCommand({removeShard: shardName}));
assert.soon(function() {
const res = st.s.adminCommand({removeShard: shardName});
+ if (!res.ok && res.code === ErrorCodes.ShardNotFound) {
+ // If the config server primary steps down right after removing the config.shards doc
+ // for the shard but before responding with "state": "completed", the mongos would retry
+ // the _configsvrRemoveShard command against the new config server primary, which would
+ // not find the removed shard in its ShardRegistry if it has done a ShardRegistry reload
+ // after the config.shards doc for the shard was removed. This would cause the command
+ // to fail with ShardNotFound.
+ return true;
+ }
assert.commandWorked(res);
return ("completed" == res.state);
}, "failed to remove shard " + shardName, kBalancerTimeoutMS);