diff options
Diffstat (limited to 'jstests/sharding/index_operations_abort_concurrent_outgoing_migrations.js')
-rw-r--r-- | jstests/sharding/index_operations_abort_concurrent_outgoing_migrations.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/jstests/sharding/index_operations_abort_concurrent_outgoing_migrations.js b/jstests/sharding/index_operations_abort_concurrent_outgoing_migrations.js index 44ffd313d71..651fde8261d 100644 --- a/jstests/sharding/index_operations_abort_concurrent_outgoing_migrations.js +++ b/jstests/sharding/index_operations_abort_concurrent_outgoing_migrations.js @@ -129,5 +129,33 @@ stepNames.forEach((stepName) => { } }); +stepNames.forEach((stepName) => { + jsTest.log(`Testing that collMod aborts concurrent outgoing migrations that are in step ${ + stepName}...`); + const collName = "testCollModMoveChunkStep" + stepName; + const ns = dbName + "." + collName; + + assert.commandWorked(st.s.adminCommand({shardCollection: ns, key: shardKey})); + + assertCommandAbortsConcurrentOutgoingMigration(st, stepName, ns, () => { + assert.commandWorked( + testDB.runCommand({collMod: collName, validator: {x: {$type: "string"}}})); + }); + + // Verify that the index command succeeds. + assert.commandFailedWithCode(st.shard0.getCollection(ns).insert({x: 1}), + ErrorCodes.DocumentValidationFailure); + + // 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})); + } +}); + st.stop(); })(); |