diff options
author | Alex Taskov <alex.taskov@mongodb.com> | 2020-05-28 18:10:14 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-08-10 13:55:44 +0000 |
commit | 6168267d96a92a9d89263042ddd4a564a993dee0 (patch) | |
tree | fc746f595b903d72673d57d9fed1337fe70195da /jstests | |
parent | a4f11ddb2d5cb4f4ff271b7e2af8ce628937200a (diff) | |
download | mongo-6168267d96a92a9d89263042ddd4a564a993dee0.tar.gz |
SERVER-48066 Don't allow update shard key concurrency test to update shard key to same value
(cherry picked from commit dc30d9e9d387a946bcabda92007c60a8fce88337)
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/concurrency/fsm_workloads/random_moveChunk_update_shard_key.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/jstests/concurrency/fsm_workloads/random_moveChunk_update_shard_key.js b/jstests/concurrency/fsm_workloads/random_moveChunk_update_shard_key.js index c034b8d06dc..cf5a430f366 100644 --- a/jstests/concurrency/fsm_workloads/random_moveChunk_update_shard_key.js +++ b/jstests/concurrency/fsm_workloads/random_moveChunk_update_shard_key.js @@ -114,12 +114,15 @@ var $config = extendWorkload($config, function($config, $super) { const partitionSizeHalf = Math.floor(this.partitionSize / 2); const partitionMedian = partitionSizeHalf + this.partition.lower; - // If moveAcrossChunks is true, move the randomly generated shardKey to the other - // half of the partition, which will be on the other chunk owned by this thread. - let newShardKey = this.partition.lower + Math.floor(Math.random() * partitionSizeHalf); - - if (moveAcrossChunks || currentShardKey >= partitionMedian) { - newShardKey += partitionSizeHalf; + let newShardKey = currentShardKey; + while (newShardKey == currentShardKey) { + // If moveAcrossChunks is true, move the randomly generated shardKey to the other + // half of the partition, which will be on the other chunk owned by this thread. + newShardKey = this.partition.lower + Math.floor(Math.random() * partitionSizeHalf); + + if (moveAcrossChunks || currentShardKey >= partitionMedian) { + newShardKey += partitionSizeHalf; + } } return { |