summaryrefslogtreecommitdiff
path: root/jstests/concurrency
diff options
context:
space:
mode:
authorWilliam Schultz <william.schultz@mongodb.com>2018-04-04 17:08:04 -0400
committerWilliam Schultz <william.schultz@mongodb.com>2018-04-04 17:14:47 -0400
commit66c537372c0aa54819adb7f72c9eda6cf8750f8e (patch)
tree18411741fc99e04f2c9d89d2c61e70f22c1bbd3f /jstests/concurrency
parent69005c338fe103892d2941791b12f5c06aae3394 (diff)
downloadmongo-66c537372c0aa54819adb7f72c9eda6cf8750f8e.tar.gz
SERVER-34051 Require autocommit=false on all transaction operations and add support
for 'startTransaction' argument This patch requires all operations that are part of a multi-statement transaction to specify an autocommit=false command argument. It also adds the 'startTransaction' command argument, which when specified as 'true' indicates that a command is the beginning of a multi-statement transaction.
Diffstat (limited to 'jstests/concurrency')
-rw-r--r--jstests/concurrency/fsm_workloads/multi_statement_transaction_simple.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/jstests/concurrency/fsm_workloads/multi_statement_transaction_simple.js b/jstests/concurrency/fsm_workloads/multi_statement_transaction_simple.js
index 18ff70c8fdf..ad3f197f644 100644
--- a/jstests/concurrency/fsm_workloads/multi_statement_transaction_simple.js
+++ b/jstests/concurrency/fsm_workloads/multi_statement_transaction_simple.js
@@ -15,6 +15,7 @@ var $config = (function() {
filter: {},
readConcern: {level: "snapshot"},
txnNumber: NumberLong(txnNumber),
+ startTransaction: true,
autocommit: false
});
assertWhenOwnColl.commandWorked(res);
@@ -26,6 +27,7 @@ var $config = (function() {
getMore: cursorId,
collection: collName,
txnNumber: NumberLong(txnNumber),
+ autocommit: false
});
assertWhenOwnColl.commandWorked(res);
res.cursor.nextBatch.forEach(function(account) {
@@ -34,8 +36,8 @@ var $config = (function() {
cursorId = res.cursor.id;
}
// commitTransaction can only be called on the admin database.
- assertWhenOwnColl.commandWorked(
- sessionDb.adminCommand({commitTransaction: 1, txnNumber: NumberLong(txnNumber)}));
+ assertWhenOwnColl.commandWorked(sessionDb.adminCommand(
+ {commitTransaction: 1, txnNumber: NumberLong(txnNumber), autocommit: false}));
return total;
}
@@ -65,13 +67,15 @@ var $config = (function() {
update: collName,
updates: [{q: {_id: transferFrom}, u: {$inc: {balance: -transferAmount}}}],
readConcern: {level: "snapshot"},
+ startTransaction: true,
autocommit: false
},
{
update: collName,
- updates: [{q: {_id: transferTo}, u: {$inc: {balance: transferAmount}}}]
+ updates: [{q: {_id: transferTo}, u: {$inc: {balance: transferAmount}}}],
+ autocommit: false
},
- {commitTransaction: 1}
+ {commitTransaction: 1, autocommit: false}
];
let hasWriteConflict;