summaryrefslogtreecommitdiff
path: root/jstests/replsets/commit_prepared_transaction_before_stable_timestamp.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/replsets/commit_prepared_transaction_before_stable_timestamp.js')
-rw-r--r--jstests/replsets/commit_prepared_transaction_before_stable_timestamp.js76
1 files changed, 38 insertions, 38 deletions
diff --git a/jstests/replsets/commit_prepared_transaction_before_stable_timestamp.js b/jstests/replsets/commit_prepared_transaction_before_stable_timestamp.js
index 71ca1189b45..56b156d8289 100644
--- a/jstests/replsets/commit_prepared_transaction_before_stable_timestamp.js
+++ b/jstests/replsets/commit_prepared_transaction_before_stable_timestamp.js
@@ -5,55 +5,55 @@
*/
(function() {
- "use strict";
- load("jstests/aggregation/extras/utils.js");
- load("jstests/core/txns/libs/prepare_helpers.js");
+"use strict";
+load("jstests/aggregation/extras/utils.js");
+load("jstests/core/txns/libs/prepare_helpers.js");
- const replTest = new ReplSetTest({nodes: 1});
- replTest.startSet();
- replTest.initiate();
+const replTest = new ReplSetTest({nodes: 1});
+replTest.startSet();
+replTest.initiate();
- const primary = replTest.getPrimary();
+const primary = replTest.getPrimary();
- const dbName = "test";
- const collName = "commit_prepared_transaction_before_stable_timestamp";
- const testDB = primary.getDB(dbName);
- const testColl = testDB.getCollection(collName);
+const dbName = "test";
+const collName = "commit_prepared_transaction_before_stable_timestamp";
+const testDB = primary.getDB(dbName);
+const testColl = testDB.getCollection(collName);
- assert.commandWorked(testDB.runCommand({create: collName}));
+assert.commandWorked(testDB.runCommand({create: collName}));
- // Make sure there is no lag between the oldest timestamp and the stable timestamp so we can
- // test that committing a prepared transaction behind the oldest timestamp succeeds.
- assert.commandWorked(primary.adminCommand({
- "configureFailPoint": 'WTSetOldestTSToStableTS',
- "mode": 'alwaysOn',
- }));
+// Make sure there is no lag between the oldest timestamp and the stable timestamp so we can
+// test that committing a prepared transaction behind the oldest timestamp succeeds.
+assert.commandWorked(primary.adminCommand({
+ "configureFailPoint": 'WTSetOldestTSToStableTS',
+ "mode": 'alwaysOn',
+}));
- const session = primary.startSession({causalConsistency: false});
- const sessionDB = session.getDatabase(dbName);
- const sessionColl = sessionDB.getCollection(collName);
+const session = primary.startSession({causalConsistency: false});
+const sessionDB = session.getDatabase(dbName);
+const sessionColl = sessionDB.getCollection(collName);
- session.startTransaction();
- assert.commandWorked(sessionColl.insert({_id: 1}));
- const prepareTimestamp = PrepareHelpers.prepareTransaction(session);
+session.startTransaction();
+assert.commandWorked(sessionColl.insert({_id: 1}));
+const prepareTimestamp = PrepareHelpers.prepareTransaction(session);
- jsTestLog("Do a majority write to advance the stable timestamp past the prepareTimestamp");
- // Doing a majority write after preparing the transaction ensures that the stable timestamp is
- // past the prepare timestamp because this write must be in the committed snapshot.
- assert.commandWorked(
- testColl.runCommand("insert", {documents: [{_id: 2}]}, {writeConcern: {w: "majority"}}));
+jsTestLog("Do a majority write to advance the stable timestamp past the prepareTimestamp");
+// Doing a majority write after preparing the transaction ensures that the stable timestamp is
+// past the prepare timestamp because this write must be in the committed snapshot.
+assert.commandWorked(
+ testColl.runCommand("insert", {documents: [{_id: 2}]}, {writeConcern: {w: "majority"}}));
- jsTestLog("Committing the transaction before the stable timestamp");
+jsTestLog("Committing the transaction before the stable timestamp");
- // Since we have advanced the stableTimestamp to be after the prepareTimestamp, when we commit
- // at the prepareTimestamp, we are certain that we are committing behind the stableTimestamp.
- assert.commandWorked(PrepareHelpers.commitTransaction(session, prepareTimestamp));
+// Since we have advanced the stableTimestamp to be after the prepareTimestamp, when we commit
+// at the prepareTimestamp, we are certain that we are committing behind the stableTimestamp.
+assert.commandWorked(PrepareHelpers.commitTransaction(session, prepareTimestamp));
- // Make sure we can see the insert from the prepared transaction.
- arrayEq(sessionColl.find().toArray(), [{_id: 1}, {_id: 2}]);
+// Make sure we can see the insert from the prepared transaction.
+arrayEq(sessionColl.find().toArray(), [{_id: 1}, {_id: 2}]);
- assert.commandWorked(
- primary.adminCommand({configureFailPoint: 'WTSetOldestTSToStableTS', mode: 'off'}));
+assert.commandWorked(
+ primary.adminCommand({configureFailPoint: 'WTSetOldestTSToStableTS', mode: 'off'}));
- replTest.stopSet();
+replTest.stopSet();
}()); \ No newline at end of file