summaryrefslogtreecommitdiff
path: root/jstests/sharding/data_size_aware_balancing_sessions_collection.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/sharding/data_size_aware_balancing_sessions_collection.js')
-rw-r--r--jstests/sharding/data_size_aware_balancing_sessions_collection.js17
1 files changed, 2 insertions, 15 deletions
diff --git a/jstests/sharding/data_size_aware_balancing_sessions_collection.js b/jstests/sharding/data_size_aware_balancing_sessions_collection.js
index 9513c44aac2..00357d4403a 100644
--- a/jstests/sharding/data_size_aware_balancing_sessions_collection.js
+++ b/jstests/sharding/data_size_aware_balancing_sessions_collection.js
@@ -12,6 +12,7 @@
load("jstests/libs/feature_flag_util.js");
load("jstests/sharding/libs/find_chunks_util.js");
+load('jstests/sharding/libs/remove_shard_util.js');
// TODO SERVER-50144 Remove this and allow orphan checking.
// This test calls removeShard which can leave docs in config.rangeDeletions in state "pending",
@@ -63,21 +64,7 @@ function addShardsToCluster(shardsToAdd) {
* decrements numShards.
*/
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);
+ removeShard(st, shardName, kBalancerTimeoutMS);
numShards--;
}