summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamy Lanka <samy.lanka@mongodb.com>2018-09-07 16:14:42 -0400
committerSamy Lanka <samy.lanka@mongodb.com>2018-09-12 11:51:29 -0400
commit96cbd0c40f585fa7b4b8d3aa92ca63a6dce63b7b (patch)
treead2a1bea0021a2d83fa45261978aaa81341fa041
parent8084a0ce51f6af543385e9292d11b6943d6b7cd4 (diff)
downloadmongo-96cbd0c40f585fa7b4b8d3aa92ca63a6dce63b7b.tar.gz
SERVER-37054 Make sure snapshot read timestamp is not older than the oldest available timestamp in prepare_conflict_read_behavior.js
-rw-r--r--jstests/core/txns/prepare_conflict_read_concern_behavior.js21
1 files changed, 13 insertions, 8 deletions
diff --git a/jstests/core/txns/prepare_conflict_read_concern_behavior.js b/jstests/core/txns/prepare_conflict_read_concern_behavior.js
index 6b9677a38a9..4ec14ff84a2 100644
--- a/jstests/core/txns/prepare_conflict_read_concern_behavior.js
+++ b/jstests/core/txns/prepare_conflict_read_concern_behavior.js
@@ -21,6 +21,9 @@
testDB.runCommand({drop: collName, writeConcern: {w: "majority"}});
assert.commandWorked(testDB.runCommand({create: collName, writeConcern: {w: "majority"}}));
+ testDB.runCommand({drop: collName2, writeConcern: {w: "majority"}});
+ assert.commandWorked(testDB.runCommand({create: collName2, writeConcern: {w: "majority"}}));
+
const session = db.getMongo().startSession({causalConsistency: false});
const sessionDB = session.getDatabase(dbName);
const sessionColl = sessionDB.getCollection(collName);
@@ -34,21 +37,20 @@
});
if (num_expected) {
+ assert(res.cursor, tojson(res));
assert.eq(res.cursor.firstBatch.length, num_expected, tojson(res));
}
return res;
};
- const clusterTimeBeforePrepare =
- assert
- .commandWorked(testColl.runCommand(
- "insert",
- {documents: [{_id: 1, in_prepared_txn: 3}], writeConcern: {w: "majority"}}))
- .operationTime;
- testColl2.runCommand("insert", {documents: [{_id: 1, in_prepared_txn: 3}]});
+ assert.commandWorked(
+ testColl.insert({_id: 1, in_prepared_txn: 3}, {writeConcern: {w: "majority"}}));
+ assert.commandWorked(testColl2.insert({_id: 1, in_prepared_txn: 3}));
session.startTransaction();
- assert.commandWorked(sessionColl.insert({_id: 2}));
+ const clusterTimeBeforePrepare =
+ assert.commandWorked(sessionColl.runCommand("insert", {documents: [{_id: 2}]}))
+ .operationTime;
const prepareTimestamp = PrepareHelpers.prepareTransaction(session);
const clusterTimeAfterPrepare =
@@ -58,6 +60,9 @@
{documents: [{_id: 3, in_prepared_txn: 3}], writeConcern: {w: "majority"}}))
.operationTime;
+ jsTestLog("prepareTimestamp: " + prepareTimestamp + " clusterTimeBeforePrepare: " +
+ clusterTimeBeforePrepare + " clusterTimeAfterPrepare: " + clusterTimeAfterPrepare);
+
assert.gt(prepareTimestamp, clusterTimeBeforePrepare);
assert.gt(clusterTimeAfterPrepare, prepareTimestamp);