diff options
author | Blake Oler <blake.oler@mongodb.com> | 2020-03-25 16:24:16 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-13 17:17:42 +0000 |
commit | f7f5c9868178b8b8b8a930446beca446d2b3407d (patch) | |
tree | 75ee18ffd0c40d293c6dc7870a4b4e4d443c27f4 /jstests | |
parent | 2fdb36056997121e483ce758fc96400ad40bb24e (diff) | |
download | mongo-f7f5c9868178b8b8b8a930446beca446d2b3407d.tar.gz |
SERVER-46040 Maintain retry state across stale config retries for sharded drop indexes
(cherry picked from commit 5403488f656db357ce123f78cf25aa63a9e5aff8)
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/sharding/drop_indexes_with_stale_config_error.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/jstests/sharding/drop_indexes_with_stale_config_error.js b/jstests/sharding/drop_indexes_with_stale_config_error.js new file mode 100644 index 00000000000..e523ab9533e --- /dev/null +++ b/jstests/sharding/drop_indexes_with_stale_config_error.js @@ -0,0 +1,38 @@ +// +// Tests that a StaleConfigError received from a shard on dropIndexes will allow the command to +// successfully complete upon the mongos' command retry. +// +// @tags: [requires_fcv_44, multiversion_incompatible] +// + +(function() { +'use strict'; + +load("jstests/sharding/libs/shard_versioning_util.js"); +load('jstests/sharding/libs/sharded_transactions_helpers.js'); + +const st = new ShardingTest({mongos: 2, shards: 2}); +const dbName = jsTestName(); +const collName = "coll"; +const ns = dbName + "." + collName; +const mongos0Coll = st.s0.getDB(dbName)[collName]; +const mongos1Coll = st.s1.getDB(dbName)[collName]; + +// Shard the collection and create an index +assert.commandWorked(st.s.adminCommand({enableSharding: dbName})); +st.ensurePrimaryShard(dbName, st.shard0.shardName); +assert.commandWorked(st.s.adminCommand({shardCollection: ns, key: {x: 1}})); +assert.commandWorked(st.s.adminCommand({split: ns, middle: {x: 0}})); +assert.commandWorked(st.s.adminCommand({moveChunk: ns, find: {x: 100}, to: st.shard1.shardName})); +flushRoutersAndRefreshShardMetadata(st, {ns}); + +assert.commandWorked(mongos0Coll.ensureIndex({x: 1})); + +// Move chunk without refreshing the recipient so that the recipient shard throws a +// StaleShardVersion error upon receiving the drop index command. +ShardVersioningUtil.moveChunkNotRefreshRecipient(st.s1, ns, st.shard1, st.shard0, {x: 100}); + +assert.commandWorked(mongos0Coll.dropIndexes({x: 1})); + +st.stop(); +})(); |