summaryrefslogtreecommitdiff
path: root/jstests/core/txns/prepare_conflict.js
diff options
context:
space:
mode:
authorSamy Lanka <samy.lanka@mongodb.com>2018-08-30 19:33:18 -0400
committerSamy Lanka <samy.lanka@mongodb.com>2018-09-05 14:10:18 -0400
commit92c166d289478bb3d40cdb08d8c7e41f083dd66d (patch)
tree7edb55a9d5def3a943e4158e0d5d659a40473778 /jstests/core/txns/prepare_conflict.js
parentd9b5ba2d1710d7f52536ab9c53c3a68329f61b90 (diff)
downloadmongo-92c166d289478bb3d40cdb08d8c7e41f083dd66d.tar.gz
SERVER-36382 Only snapshot, lineariable and afterClusterTime reads block on prepare conflicts
Diffstat (limited to 'jstests/core/txns/prepare_conflict.js')
-rw-r--r--jstests/core/txns/prepare_conflict.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/jstests/core/txns/prepare_conflict.js b/jstests/core/txns/prepare_conflict.js
index 870af78909a..a06ddd296f0 100644
--- a/jstests/core/txns/prepare_conflict.js
+++ b/jstests/core/txns/prepare_conflict.js
@@ -5,6 +5,7 @@
*/
(function() {
"use strict";
+ load("jstests/core/txns/libs/prepare_helpers.js");
const dbName = "test";
const collName = "prepare_conflict";
@@ -14,9 +15,15 @@
testColl.drop({writeConcern: {w: "majority"}});
assert.commandWorked(testDB.runCommand({create: collName, writeConcern: {w: "majority"}}));
- function assertPrepareConflict(filter) {
+ function assertPrepareConflict(filter, clusterTime) {
assert.commandFailedWithCode(
- testDB.runCommand({find: collName, filter: filter, maxTimeMS: 1000}),
+ // Use afterClusterTime read to make sure that it will block on a prepare conflict.
+ testDB.runCommand({
+ find: collName,
+ filter: filter,
+ readConcern: {afterClusterTime: clusterTime},
+ maxTimeMS: 1000
+ }),
ErrorCodes.MaxTimeMSExpired);
let prepareConflicted = false;
@@ -55,13 +62,13 @@
updates: [{q: txnDoc, u: {$inc: {x: 1}}}],
}));
- assert.commandWorked(sessionDB.adminCommand({prepareTransaction: 1}));
+ const prepareTimestamp = PrepareHelpers.prepareTransaction(session);
// Conflict on _id of prepared document.
- assertPrepareConflict({_id: txnDoc._id});
+ assertPrepareConflict({_id: txnDoc._id}, prepareTimestamp);
// Conflict on field that could be added to a prepared document.
- assertPrepareConflict({randomField: "random"});
+ assertPrepareConflict({randomField: "random"}, prepareTimestamp);
// No conflict on _id of a non-prepared document.
assert.commandWorked(testDB.runCommand({find: collName, filter: {_id: otherDoc._id}}));