diff options
author | Cheahuychou Mao <cheahuychou.mao@mongodb.com> | 2020-01-13 21:22:34 +0000 |
---|---|---|
committer | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2020-01-27 15:38:04 -0500 |
commit | f25d0d92376ecd88bbb7cd54b303623d93a10f31 (patch) | |
tree | 725c0a12cd39253c7997bc56f22168791f31b7b2 | |
parent | e7c6df9b0634c590b218774be15f166ce85e6006 (diff) | |
download | mongo-f25d0d92376ecd88bbb7cd54b303623d93a10f31.tar.gz |
SERVER-45513 Make index_operations_abort_concurrent_outgoing_migrations.js only check that index commands did not run on recipient when the commands are run after steady state is reached
-rw-r--r-- | jstests/libs/override_methods/check_indexes_consistent_across_cluster.js | 2 | ||||
-rw-r--r-- | jstests/sharding/index_operations_abort_concurrent_outgoing_migrations.js | 21 |
2 files changed, 20 insertions, 3 deletions
diff --git a/jstests/libs/override_methods/check_indexes_consistent_across_cluster.js b/jstests/libs/override_methods/check_indexes_consistent_across_cluster.js index 228d62e6bab..465b09c8ccc 100644 --- a/jstests/libs/override_methods/check_indexes_consistent_across_cluster.js +++ b/jstests/libs/override_methods/check_indexes_consistent_across_cluster.js @@ -94,7 +94,7 @@ ShardingTest.prototype.checkIndexesConsistentAcrossCluster = function() { } // Find inconsistent indexes. For the example above: - // {"rs0": [{"spec" : {"v" : 2, "key" : {"_id" : 1}, "name" : "_id_"}}], "rs1" : []}; + // {"rs0": [{"spec" : {"v" : 2, "key" : {"x" : 1}, "name" : "x_1"}}], "rs1" : []}; const inconsistentIndexesOnShard = {}; let isConsistent = true; for (const indexDoc of indexDocs) { diff --git a/jstests/sharding/index_operations_abort_concurrent_outgoing_migrations.js b/jstests/sharding/index_operations_abort_concurrent_outgoing_migrations.js index 0ca446022da..6a350b90693 100644 --- a/jstests/sharding/index_operations_abort_concurrent_outgoing_migrations.js +++ b/jstests/sharding/index_operations_abort_concurrent_outgoing_migrations.js @@ -105,7 +105,15 @@ stepNames.forEach((stepName) => { // Verify that the index command succeeds. ShardedIndexUtil.assertIndexDoesNotExistOnShard(st.shard0, dbName, collName, index); - ShardedIndexUtil.assertIndexExistsOnShard(st.shard1, dbName, collName, index); + + // If dropIndexes is run after the migration has reached the steady state, shard1 + // is expected to finish cloning the collection options and indexes before the migration + // aborts. However, if dropIndexes is run after the cloning step starts but before the + // steady state is reached, the migration could abort before shard1 gets to clone the + // collection options and indexes so listIndexes could fail with NamespaceNotFound. + if (stepName == moveChunkStepNames.reachedSteadyState) { + ShardedIndexUtil.assertIndexExistsOnShard(st.shard1, dbName, collName, index); + } }); stepNames.forEach((stepName) => { @@ -124,7 +132,16 @@ stepNames.forEach((stepName) => { // Verify that the index command succeeds. assert.commandFailedWithCode(st.shard0.getCollection(ns).insert({x: 1}), ErrorCodes.DocumentValidationFailure); - assert.commandWorked(st.shard1.getCollection(ns).insert({x: 1})); + + // If collMod is run after the migration has reached the steady state, shard1 + // will not perform schema validation because the validation rule just does not + // exist when shard1 clones the collection options from shard0. However, if collMod + // is run after the cloning step starts but before the steady state is reached, + // shard0 may have the validation rule when shard1 does the cloning so shard1 may + // or may not perform schema validation. + if (stepName == moveChunkStepNames.reachedSteadyState) { + assert.commandWorked(st.shard1.getCollection(ns).insert({x: 1})); + } }); assert.commandWorked(st.s.adminCommand({setFeatureCompatibilityVersion: lastStableFCV})); |