summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorSiyuan Zhou <siyuan.zhou@mongodb.com>2018-10-22 21:57:16 -0400
committerSiyuan Zhou <siyuan.zhou@mongodb.com>2018-11-08 18:11:44 -0500
commit4fb38d9c10123321dada6fe1be477f9cb99732a7 (patch)
tree0a84c02c5445e3ce996bf3e4efefbcfaf64b7a07 /jstests
parenta955b238b22c81c3cc4ec840aaf8e25d280ac9c8 (diff)
downloadmongo-4fb38d9c10123321dada6fe1be477f9cb99732a7.tar.gz
SERVER-37179 Pull out starting transaction from session checkout and push it down to before command execution.
Transaction will begin or continue after waiting for read concern. If an error is thrown on starting transaction, it'll be able to wait for write concern if a write concern is specified.
Diffstat (limited to 'jstests')
-rw-r--r--jstests/concurrency/fsm_workload_helpers/snapshot_read_utils.js7
-rw-r--r--jstests/concurrency/fsm_workloads/snapshot_read_kill_operations.js7
-rw-r--r--jstests/core/txns/disallow_operations_on_prepared_transaction.js1
-rw-r--r--jstests/core/txns/empty_prepare.js5
-rw-r--r--jstests/core/txns/errors_on_committed_transaction.js2
-rw-r--r--jstests/core/txns/multi_statement_transaction_command_args.js2
6 files changed, 19 insertions, 5 deletions
diff --git a/jstests/concurrency/fsm_workload_helpers/snapshot_read_utils.js b/jstests/concurrency/fsm_workload_helpers/snapshot_read_utils.js
index eef0148b26a..a020855727b 100644
--- a/jstests/concurrency/fsm_workload_helpers/snapshot_read_utils.js
+++ b/jstests/concurrency/fsm_workload_helpers/snapshot_read_utils.js
@@ -19,6 +19,13 @@ function parseCursor(cmdResult) {
*/
function doSnapshotFind(sortByAscending, collName, data, findErrorCodes) {
// Reset txnNumber and stmtId for this transaction.
+ const abortErrorCodes = [
+ ErrorCodes.NoSuchTransaction,
+ ErrorCodes.TransactionCommitted,
+ ErrorCodes.TransactionTooOld,
+ ErrorCodes.Interrupted
+ ];
+ abortTransaction(data.sessionDb, data.txnNumber, abortErrorCodes);
data.txnNumber++;
data.stmtId = 0;
diff --git a/jstests/concurrency/fsm_workloads/snapshot_read_kill_operations.js b/jstests/concurrency/fsm_workloads/snapshot_read_kill_operations.js
index de2ca10cd31..52acfe5bb5b 100644
--- a/jstests/concurrency/fsm_workloads/snapshot_read_kill_operations.js
+++ b/jstests/concurrency/fsm_workloads/snapshot_read_kill_operations.js
@@ -44,6 +44,13 @@ var $config = (function() {
},
incrementTxnNumber: function incrementTxnNumber(db, collName) {
+ const abortErrorCodes = [
+ ErrorCodes.NoSuchTransaction,
+ ErrorCodes.TransactionCommitted,
+ ErrorCodes.TransactionTooOld,
+ ErrorCodes.Interrupted
+ ];
+ abortTransaction(this.sessionDb, this.txnNumber, abortErrorCodes);
this.txnNumber++;
},
diff --git a/jstests/core/txns/disallow_operations_on_prepared_transaction.js b/jstests/core/txns/disallow_operations_on_prepared_transaction.js
index 4e6c879b995..f75218edb45 100644
--- a/jstests/core/txns/disallow_operations_on_prepared_transaction.js
+++ b/jstests/core/txns/disallow_operations_on_prepared_transaction.js
@@ -83,7 +83,6 @@
assert.commandFailedWithCode(sessionDB.runCommand({
findandmodify: collName,
remove: true,
- readConcern: {level: "snapshot"},
txnNumber: NumberLong(session.getTxnNumber_forTesting()),
stmtId: NumberInt(1),
autocommit: false
diff --git a/jstests/core/txns/empty_prepare.js b/jstests/core/txns/empty_prepare.js
index 3b8dc8d3051..3669e361737 100644
--- a/jstests/core/txns/empty_prepare.js
+++ b/jstests/core/txns/empty_prepare.js
@@ -25,8 +25,9 @@
session.startTransaction();
// TODO SERVER-35787: make this fail with NoSuchTransaction.
- assert.commandFailedWithCode(sessionDB.adminCommand({prepareTransaction: 1}),
- ErrorCodes.OperationNotSupportedInTransaction);
+ assert.commandFailedWithCode(
+ sessionDB.adminCommand({prepareTransaction: 1}),
+ [ErrorCodes.OperationNotSupportedInTransaction, ErrorCodes.NoSuchTransaction]);
session.abortTransaction_forTesting();
// ---- Test 2. Only reads before prepare ----
diff --git a/jstests/core/txns/errors_on_committed_transaction.js b/jstests/core/txns/errors_on_committed_transaction.js
index 69e5a0789cc..e38b307c8e4 100644
--- a/jstests/core/txns/errors_on_committed_transaction.js
+++ b/jstests/core/txns/errors_on_committed_transaction.js
@@ -51,7 +51,7 @@
autocommit: false,
startTransaction: true
}),
- ErrorCodes.ConflictingOperationInProgress);
+ ErrorCodes.OperationNotSupportedInTransaction);
// Call commit on committed transaction without shell helper.
jsTestLog("Test that calling commit with invalid fields on a committed transaction fails.");
diff --git a/jstests/core/txns/multi_statement_transaction_command_args.js b/jstests/core/txns/multi_statement_transaction_command_args.js
index 45a4eb13955..90ed7dd9a7a 100644
--- a/jstests/core/txns/multi_statement_transaction_command_args.js
+++ b/jstests/core/txns/multi_statement_transaction_command_args.js
@@ -145,7 +145,7 @@
txnNumber: NumberLong(txnNumber),
autocommit: false
}),
- ErrorCodes.NoSuchTransaction);
+ [ErrorCodes.InvalidOptions, ErrorCodes.NoSuchTransaction]);
jsTestLog("Try to begin a transaction with startTransaction=false and autocommit=false");
txnNumber++;