summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/libs/override_methods/check_indexes_consistent_across_cluster.js2
-rw-r--r--jstests/sharding/index_operations_abort_concurrent_outgoing_migrations.js21
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}));