summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorJudah Schvimer <judah@mongodb.com>2018-05-21 13:17:03 -0400
committerJudah Schvimer <judah@mongodb.com>2018-05-21 13:17:03 -0400
commitb64de307169891f859c29f207e712ed0eb3cd2a2 (patch)
tree7ae081a06b6d91303b7d0e86c301c8f9b135a570 /jstests
parent6389499b09a899c5bc70e460338fb814b24640da (diff)
downloadmongo-b64de307169891f859c29f207e712ed0eb3cd2a2.tar.gz
SERVER-30724 Initial sync waits for oplog visibility before beginning clone
Diffstat (limited to 'jstests')
-rw-r--r--jstests/replsets/initial_sync_oplog_visibility.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/jstests/replsets/initial_sync_oplog_visibility.js b/jstests/replsets/initial_sync_oplog_visibility.js
new file mode 100644
index 00000000000..9002a5f9b23
--- /dev/null
+++ b/jstests/replsets/initial_sync_oplog_visibility.js
@@ -0,0 +1,52 @@
+/**
+ * Test that we wait for oplog visibility before beginning initial sync.
+ */
+(function() {
+ 'use strict';
+ load("jstests/libs/check_log.js");
+
+ var name = 'initial_sync_oplog_visibility';
+
+ var replTest = new ReplSetTest({name: name, nodes: 1});
+ replTest.startSet();
+ replTest.initiate();
+ var primary = replTest.getPrimary();
+
+ var firstColl = "hangColl";
+ var secondColl = "secondColl";
+
+ // Create both collections.
+ assert.writeOK(primary.getDB(name)[firstColl].insert({init: 1}));
+ assert.writeOK(primary.getDB(name)[secondColl].insert({init: 1}));
+
+ jsTestLog("Add a node to initial sync.");
+ var secondary = replTest.add({});
+ assert.commandWorked(secondary.adminCommand(
+ {configureFailPoint: 'initialSyncHangBeforeOplogVisibility', mode: 'alwaysOn'}));
+ replTest.reInitiate();
+ checkLog.contains(secondary,
+ "initial sync - initialSyncHangBeforeOplogVisibility fail point enabled");
+
+ // Start an insert that will hang in a parallel shell.
+ assert.commandWorked(
+ primary.adminCommand({configureFailPoint: 'hangOnInsertObserver', mode: 'alwaysOn'}));
+ const awaitInsertShell = startParallelShell(function() {
+ var name = 'initial_sync_oplog_visibility';
+ var firstColl = "hangColl";
+ assert.writeOK(db.getSiblingDB(name)[firstColl].insert({a: 1}));
+ }, primary.port);
+ checkLog.contains(primary, "op observer - hangOnInsertObserver fail point enabled");
+
+ // Let initial sync finish and fail.
+ assert.commandWorked(secondary.adminCommand(
+ {configureFailPoint: 'initialSyncHangBeforeOplogVisibility', mode: 'off'}));
+ checkLog.contains(secondary, "initial sync attempt failed");
+
+ // Let the insert and the initial sync finish.
+ assert.commandWorked(
+ primary.adminCommand({configureFailPoint: 'hangOnInsertObserver', mode: 'off'}));
+ awaitInsertShell();
+ replTest.awaitSecondaryNodes();
+
+ replTest.stopSet();
+})(); \ No newline at end of file