diff options
author | Matthew Saltz <matthew.saltz@mongodb.com> | 2020-09-03 18:53:26 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-09-03 23:45:15 +0000 |
commit | 1cad5256f939929a40fa53074bb7a502ece9f623 (patch) | |
tree | 8e938121db665b8fca978b2246aaab49b2eec18d | |
parent | a0b14e0a81ede374e18015e8c9342379659b54a5 (diff) | |
download | mongo-1cad5256f939929a40fa53074bb7a502ece9f623.tar.gz |
SERVER-50618 Make sharding_statistics_server_status.js retry moveChunk commands on ConflictingOperationInProgress (patch 2)
-rw-r--r-- | jstests/sharding/sharding_statistics_server_status.js | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/jstests/sharding/sharding_statistics_server_status.js b/jstests/sharding/sharding_statistics_server_status.js index 2c21aa2aa17..a61a93c60a8 100644 --- a/jstests/sharding/sharding_statistics_server_status.js +++ b/jstests/sharding/sharding_statistics_server_status.js @@ -63,7 +63,28 @@ function checkServerStatusAbortedMigrationCount(shardConn, count) { function runConcurrentMoveChunk(host, ns, toShard) { const mongos = new Mongo(host); - return mongos.adminCommand({moveChunk: ns, find: {_id: 1}, to: toShard}); + // Helper function to run moveChunk, retrying on ConflictingOperationInProgress. We need to + // retry on ConflictingOperationInProgress to handle the following case: + // 1. One test case does a moveChunk, expecting it to fail. It fails and completes on the donor + // and returns to the test, while the recipient is still lagging for some reason and has not + // completed. + // 2. In the next test case, we attempt a moveChunk involving the same chunk and shards, but the + // previous moveChunk is still in progress on the recipient shard from the previous migration, + // causing this new moveChunk to return ConflictingOperationInProgress. + // + // This is expected behavior, so we retry until success or until some other unexpected error + // occurs. + function runMoveChunkUntilSuccessOrUnexpectedError() { + let result = mongos.adminCommand({moveChunk: ns, find: {_id: 1}, to: toShard}); + let shouldRetry = (result.hasOwnProperty("code") && + result.code == ErrorCodes.ConflictingOperationInProgress); + if (shouldRetry) { + jsTestLog("Retrying moveChunk due to ConflictingOperationInProgress"); + } + return shouldRetry ? runMoveChunkUntilSuccessOrUnexpectedError() : result; + } + // Kick off the recursive helper function. + return runMoveChunkUntilSuccessOrUnexpectedError(); } function runConcurrentRead(host, dbName, collName) { |