diff options
author | Dianna Hohensee <dianna.hohensee@10gen.com> | 2017-10-18 14:19:22 -0400 |
---|---|---|
committer | Dianna Hohensee <dianna.hohensee@10gen.com> | 2017-11-08 09:39:10 -0500 |
commit | 1df38e15d137719462b3609f7c45d5cdce253f7b (patch) | |
tree | 39a83859a517c506949346656135329a5597ef2b /jstests/sharding | |
parent | 11e68f03f22a040328f34fa636bd7b69a215d16b (diff) | |
download | mongo-1df38e15d137719462b3609f7c45d5cdce253f7b.tar.gz |
SERVER-31275 Ensure causal consistency guarantees on secondaries during chunk migration commits, and fully invalidate metadata.
Diffstat (limited to 'jstests/sharding')
3 files changed, 33 insertions, 14 deletions
diff --git a/jstests/sharding/safe_secondary_reads_drop_recreate.js b/jstests/sharding/safe_secondary_reads_drop_recreate.js index d5be9f69efd..4e43675e86f 100644 --- a/jstests/sharding/safe_secondary_reads_drop_recreate.js +++ b/jstests/sharding/safe_secondary_reads_drop_recreate.js @@ -562,13 +562,21 @@ // Do any test-specific setup. test.setUp(staleMongos); + // Do dummy read from the stale mongos so it loads the routing table into memory once. + // Additionally, do a secondary read to ensure that the secondary has loaded the initial + // routing table -- the first read to the primary will refresh the mongos' shardVersion, + // which will then be used against the secondary to ensure the secondary is fresh. + assert.commandWorked(staleMongos.getDB(db).runCommand({find: coll})); + assert.commandWorked(freshMongos.getDB(db).runCommand({ + find: coll, + $readPreference: {mode: 'secondary'}, + readConcern: {'level': 'local'} + })); + // Turn on system profiler on both secondaries. assert.commandWorked(st.rs0.getSecondary().getDB(db).setProfilingLevel(2)); assert.commandWorked(st.rs1.getSecondary().getDB(db).setProfilingLevel(2)); - // Do dummy read from the stale mongos so it loads the routing table into memory once. - assert.commandWorked(staleMongos.getDB(db).runCommand({find: coll})); - scenarios[scenario](staleMongos, freshMongos, test, commandProfile); // Clean up the database by dropping it; this is the only way to drop the profiler diff --git a/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js b/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js index 6d0248e60b6..aa9ca818d8c 100644 --- a/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js +++ b/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js @@ -391,8 +391,13 @@ assert.commandWorked(freshMongos.adminCommand({shardCollection: nss, key: {x: 1}})); assert.commandWorked(freshMongos.adminCommand({split: nss, middle: {x: 0}})); - // Do dummy read from the stale mongos so that it loads the routing table into memory once. + // Do dummy read from the stale mongos so it loads the routing table into memory once. + // Additionally, do a secondary read to ensure that the secondary has loaded the initial + // routing table -- the first read to the primary will refresh the mongos' shardVersion, + // which will then be used against the secondary to ensure the secondary is fresh. assert.commandWorked(staleMongos.getDB(db).runCommand({find: coll})); + assert.commandWorked(freshMongos.getDB(db).runCommand( + {find: coll, $readPreference: {mode: 'secondary'}, readConcern: {'level': 'local'}})); // Do any test-specific setup. test.setUp(staleMongos); diff --git a/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js b/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js index 7204a4b83c7..129197b42a8 100644 --- a/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js +++ b/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js @@ -332,13 +332,6 @@ let freshMongos = st.s0; let staleMongos = st.s1; - assert.commandWorked(staleMongos.adminCommand({enableSharding: db})); - st.ensurePrimaryShard(db, st.shard0.shardName); - - // Turn on system profiler on secondaries to collect data on all database operations. - assert.commandWorked(donorShardSecondary.getDB(db).setProfilingLevel(2)); - assert.commandWorked(recipientShardSecondary.getDB(db).setProfilingLevel(2)); - let res = st.s.adminCommand({listCommands: 1}); assert.commandWorked(res); @@ -356,15 +349,26 @@ jsTest.log("testing command " + tojson(test.command)); + assert.commandWorked(staleMongos.adminCommand({enableSharding: db})); + st.ensurePrimaryShard(db, st.shard0.shardName); assert.commandWorked(staleMongos.adminCommand({shardCollection: nss, key: {x: 1}})); assert.commandWorked(staleMongos.adminCommand({split: nss, middle: {x: 0}})); - // Do dummy read from the stale mongos so that it loads the routing table into memory once. + // Do dummy read from the stale mongos so it loads the routing table into memory once. + // Additionally, do a secondary read to ensure that the secondary has loaded the initial + // routing table -- the first read to the primary will refresh the mongos' shardVersion, + // which will then be used against the secondary to ensure the secondary is fresh. assert.commandWorked(staleMongos.getDB(db).runCommand({find: coll})); + assert.commandWorked(freshMongos.getDB(db).runCommand( + {find: coll, $readPreference: {mode: 'secondary'}, readConcern: {'level': 'local'}})); // Do any test-specific setup. test.setUp(staleMongos); + // Turn on system profiler on secondaries to collect data on all database operations. + assert.commandWorked(donorShardSecondary.getDB(db).setProfilingLevel(2)); + assert.commandWorked(recipientShardSecondary.getDB(db).setProfilingLevel(2)); + // Do a moveChunk from the fresh mongos to make the other mongos stale. // Use {w:2} (all) write concern so the metadata change gets persisted to the secondary // before stalely versioned commands are sent against the secondary. @@ -450,8 +454,10 @@ }); } - // Clean up the collection by dropping it. This also drops all associated indexes. - assert.commandWorked(freshMongos.getDB(db).runCommand({drop: coll})); + // Clean up the database by dropping it; this is the only way to drop the profiler + // collection on secondaries. This also drops all associated indexes. + // Do this from staleMongos, so staleMongos purges the database entry from its cache. + assert.commandWorked(staleMongos.getDB(db).runCommand({dropDatabase: 1})); } st.stop(); |