summaryrefslogtreecommitdiff
path: root/jstests/replsets/read_committed_no_snapshots.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/replsets/read_committed_no_snapshots.js')
-rw-r--r--jstests/replsets/read_committed_no_snapshots.js123
1 files changed, 60 insertions, 63 deletions
diff --git a/jstests/replsets/read_committed_no_snapshots.js b/jstests/replsets/read_committed_no_snapshots.js
index 59524c24bd2..9cb4835727c 100644
--- a/jstests/replsets/read_committed_no_snapshots.js
+++ b/jstests/replsets/read_committed_no_snapshots.js
@@ -8,77 +8,74 @@
load("jstests/replsets/rslib.js"); // For reconfig and startSetIfSupportsReadMajority.
(function() {
- "use strict";
+"use strict";
- // Set up a set and grab things for later.
- var name = "read_committed_no_snapshots";
- var replTest = new ReplSetTest({
- name: name,
- nodes: [
- {},
- {rsConfig: {priority: 0}},
- {
- setParameter: {"failpoint.disableSnapshotting": "{'mode':'alwaysOn'}"},
- rsConfig: {priority: 0}
- }
- ],
- nodeOptions: {enableMajorityReadConcern: ''},
- settings: {protocolVersion: 1}
- });
+// Set up a set and grab things for later.
+var name = "read_committed_no_snapshots";
+var replTest = new ReplSetTest({
+ name: name,
+ nodes: [
+ {},
+ {rsConfig: {priority: 0}},
+ {
+ setParameter: {"failpoint.disableSnapshotting": "{'mode':'alwaysOn'}"},
+ rsConfig: {priority: 0}
+ }
+ ],
+ nodeOptions: {enableMajorityReadConcern: ''},
+ settings: {protocolVersion: 1}
+});
- if (!startSetIfSupportsReadMajority(replTest)) {
- jsTest.log("skipping test since storage engine doesn't support committed reads");
- replTest.stopSet();
- return;
- }
+if (!startSetIfSupportsReadMajority(replTest)) {
+ jsTest.log("skipping test since storage engine doesn't support committed reads");
+ replTest.stopSet();
+ return;
+}
- // Cannot wait for a stable recovery timestamp due to the no-snapshot secondary.
- replTest.initiateWithAnyNodeAsPrimary(
- null, "replSetInitiate", {doNotWaitForStableRecoveryTimestamp: true});
+// Cannot wait for a stable recovery timestamp due to the no-snapshot secondary.
+replTest.initiateWithAnyNodeAsPrimary(
+ null, "replSetInitiate", {doNotWaitForStableRecoveryTimestamp: true});
- // Get connections and collection.
- var primary = replTest.getPrimary();
- var healthySecondary = replTest._slaves[0];
- healthySecondary.setSlaveOk();
- var noSnapshotSecondary = replTest._slaves[1];
- noSnapshotSecondary.setSlaveOk();
+// Get connections and collection.
+var primary = replTest.getPrimary();
+var healthySecondary = replTest._slaves[0];
+healthySecondary.setSlaveOk();
+var noSnapshotSecondary = replTest._slaves[1];
+noSnapshotSecondary.setSlaveOk();
- // Do a write, wait for it to replicate, and ensure it is visible.
- var res = primary.getDB(name).runCommandWithMetadata( //
- {
- insert: "foo",
- documents: [{_id: 1, state: 0}],
- writeConcern: {w: "majority", wtimeout: ReplSetTest.kDefaultTimeoutMS}
- },
- {"$replData": 1});
- assert.commandWorked(res.commandReply);
+// Do a write, wait for it to replicate, and ensure it is visible.
+var res = primary.getDB(name).runCommandWithMetadata( //
+ {
+ insert: "foo",
+ documents: [{_id: 1, state: 0}],
+ writeConcern: {w: "majority", wtimeout: ReplSetTest.kDefaultTimeoutMS}
+ },
+ {"$replData": 1});
+assert.commandWorked(res.commandReply);
- // We need to propagate the lastOpVisible from the primary as afterOpTime in the secondaries to
- // ensure we wait for the write to be in the majority committed view.
- var lastOp = res.commandReply["$replData"].lastOpVisible;
+// We need to propagate the lastOpVisible from the primary as afterOpTime in the secondaries to
+// ensure we wait for the write to be in the majority committed view.
+var lastOp = res.commandReply["$replData"].lastOpVisible;
- // Timeout is based on heartbeat timeout.
- assert.commandWorked(healthySecondary.getDB(name).foo.runCommand(
- 'find',
- {"readConcern": {"level": "majority", "afterOpTime": lastOp}, "maxTimeMS": 10 * 1000}));
+// Timeout is based on heartbeat timeout.
+assert.commandWorked(healthySecondary.getDB(name).foo.runCommand(
+ 'find', {"readConcern": {"level": "majority", "afterOpTime": lastOp}, "maxTimeMS": 10 * 1000}));
- // Ensure maxTimeMS times out while waiting for this snapshot
- assert.commandFailedWithCode(
- noSnapshotSecondary.getDB(name).foo.runCommand(
- 'find', {"readConcern": {"level": "majority"}, "maxTimeMS": 1000}),
- ErrorCodes.MaxTimeMSExpired);
+// Ensure maxTimeMS times out while waiting for this snapshot
+assert.commandFailedWithCode(noSnapshotSecondary.getDB(name).foo.runCommand(
+ 'find', {"readConcern": {"level": "majority"}, "maxTimeMS": 1000}),
+ ErrorCodes.MaxTimeMSExpired);
- // Reconfig to make the no-snapshot secondary the primary
- var config = primary.getDB("local").system.replset.findOne();
- config.members[0].priority = 0;
- config.members[2].priority = 1;
- config.version++;
- primary = reconfig(replTest, config, true);
+// Reconfig to make the no-snapshot secondary the primary
+var config = primary.getDB("local").system.replset.findOne();
+config.members[0].priority = 0;
+config.members[2].priority = 1;
+config.version++;
+primary = reconfig(replTest, config, true);
- // Ensure maxTimeMS times out while waiting for this snapshot
- assert.commandFailedWithCode(
- primary.getSiblingDB(name).foo.runCommand(
- 'find', {"readConcern": {"level": "majority"}, "maxTimeMS": 1000}),
- ErrorCodes.MaxTimeMSExpired);
- replTest.stopSet();
+// Ensure maxTimeMS times out while waiting for this snapshot
+assert.commandFailedWithCode(primary.getSiblingDB(name).foo.runCommand(
+ 'find', {"readConcern": {"level": "majority"}, "maxTimeMS": 1000}),
+ ErrorCodes.MaxTimeMSExpired);
+replTest.stopSet();
})();