summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2016-11-14 15:35:28 -0500
committerRandolph Tan <randolph@10gen.com>2016-11-14 16:58:37 -0500
commitd0ed5e615b0d695c5f12e04fe598138d5ad0854c (patch)
treeb59b88dbc88ecfb7e029af7b30f19b457171ce69
parente82b201cf7d17f64f54b57f58dc9668527ab49b1 (diff)
downloadmongo-d0ed5e615b0d695c5f12e04fe598138d5ad0854c.tar.gz
SERVER-27026 Ensure that shard_identity_rollback.js waits for replication before shutting down primary
-rw-r--r--jstests/sharding/shard_identity_rollback.js19
1 files changed, 13 insertions, 6 deletions
diff --git a/jstests/sharding/shard_identity_rollback.js b/jstests/sharding/shard_identity_rollback.js
index a0c4d9f1791..ac899c5edce 100644
--- a/jstests/sharding/shard_identity_rollback.js
+++ b/jstests/sharding/shard_identity_rollback.js
@@ -17,12 +17,11 @@
var secondaries = replTest.getSecondaries();
var configConnStr = st.configRS.getURL();
- var shardIdentityDoc = {
- _id: 'shardIdentity',
- configsvrConnectionString: configConnStr,
- shardName: 'newShard',
- clusterId: ObjectId()
- };
+ // Wait for the secondaries to have the latest oplog entries before stopping the fetcher to
+ // avoid the situation where one of the secondaries will not have an overlapping oplog with
+ // the other nodes once the primary is killed.
+ replTest.awaitSecondaryNodes();
+ replTest.awaitReplication();
nodes.forEach(function(node) {
// Pause bgsync so it doesn't keep trying to sync from other nodes.
@@ -34,6 +33,14 @@
});
jsTest.log("inserting shardIdentity document to primary that shouldn't replicate");
+
+ var shardIdentityDoc = {
+ _id: 'shardIdentity',
+ configsvrConnectionString: configConnStr,
+ shardName: 'newShard',
+ clusterId: ObjectId()
+ };
+
assert.writeOK(priConn.getDB('admin').system.version.update(
{_id: 'shardIdentity'}, shardIdentityDoc, {upsert: true}));