summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buildscripts/resmokeconfig/suites/concurrency_sharded_replication.yml4
-rw-r--r--buildscripts/resmokeconfig/suites/concurrency_sharded_replication_local_read_write_multi_stmt_txn.yml2
-rw-r--r--buildscripts/resmokeconfig/suites/concurrency_sharded_replication_local_read_write_multi_stmt_txn_with_balancer.yml2
-rw-r--r--buildscripts/resmokeconfig/suites/concurrency_sharded_replication_multi_stmt_txn.yml2
-rw-r--r--buildscripts/resmokeconfig/suites/concurrency_sharded_replication_multi_stmt_txn_with_balancer.yml2
-rw-r--r--buildscripts/resmokeconfig/suites/concurrency_sharded_replication_with_balancer.yml4
-rw-r--r--jstests/concurrency/fsm_workload_helpers/cleanup_txns.js7
-rw-r--r--jstests/concurrency/fsm_workload_helpers/snapshot_read_utils.js1
-rw-r--r--jstests/concurrency/fsm_workloads/multi_statement_transaction_atomicity_isolation.js1
-rw-r--r--jstests/concurrency/fsm_workloads/snapshot_read_kill_operations.js13
-rw-r--r--src/mongo/s/transaction_router.cpp11
-rw-r--r--src/mongo/s/transaction_router.h3
12 files changed, 24 insertions, 28 deletions
diff --git a/buildscripts/resmokeconfig/suites/concurrency_sharded_replication.yml b/buildscripts/resmokeconfig/suites/concurrency_sharded_replication.yml
index bb0ad70e109..f5700104507 100644
--- a/buildscripts/resmokeconfig/suites/concurrency_sharded_replication.yml
+++ b/buildscripts/resmokeconfig/suites/concurrency_sharded_replication.yml
@@ -112,12 +112,8 @@ selector:
# router tries to commit, it may not know the full participant list.
- jstests/concurrency/fsm_workloads/multi_statement_transaction_all_commands_same_session.js
- # TODO SERVER-38190: Killing an operation committing a prepared txn can crash.
# TODO SERVER-38297: Killing session on a secondary applying a prepare oplog entry can crash.
- # TODO SERVER-38299: Killing an operation preparing a transaction can crash.
- jstests/concurrency/fsm_workloads/multi_statement_transaction_kill_sessions_atomicity_isolation.js
- - jstests/concurrency/fsm_workloads/snapshot_read_kill_op_only.js
- - jstests/concurrency/fsm_workloads/snapshot_read_kill_operations.js
exclude_with_any_tags:
- requires_replication
diff --git a/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_local_read_write_multi_stmt_txn.yml b/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_local_read_write_multi_stmt_txn.yml
index c5429ac8c97..0b8b8bd4148 100644
--- a/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_local_read_write_multi_stmt_txn.yml
+++ b/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_local_read_write_multi_stmt_txn.yml
@@ -115,9 +115,7 @@ selector:
# router tries to commit, it may not know the full participant list.
- jstests/concurrency/fsm_workloads/multi_statement_transaction_all_commands_same_session.js
- # TODO SERVER-38190: Killing an operation committing a prepared txn can crash.
# TODO SERVER-38297: Killing session on a secondary applying a prepare oplog entry can crash.
- # TODO SERVER-38299: Killing an operation preparing a transaction can crash.
- jstests/concurrency/fsm_workloads/multi_statement_transaction_kill_sessions_atomicity_isolation.js
##
diff --git a/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_local_read_write_multi_stmt_txn_with_balancer.yml b/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_local_read_write_multi_stmt_txn_with_balancer.yml
index 096f6854118..def152cc8ad 100644
--- a/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_local_read_write_multi_stmt_txn_with_balancer.yml
+++ b/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_local_read_write_multi_stmt_txn_with_balancer.yml
@@ -115,9 +115,7 @@ selector:
# router tries to commit, it may not know the full participant list.
- jstests/concurrency/fsm_workloads/multi_statement_transaction_all_commands_same_session.js
- # TODO SERVER-38190: Killing an operation committing a prepared txn can crash.
# TODO SERVER-38297: Killing session on a secondary applying a prepare oplog entry can crash.
- # TODO SERVER-38299: Killing an operation preparing a transaction can crash.
- jstests/concurrency/fsm_workloads/multi_statement_transaction_kill_sessions_atomicity_isolation.js
# Expects reads to die with a particular error, but other errors are possible if the read is part
diff --git a/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_multi_stmt_txn.yml b/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_multi_stmt_txn.yml
index 09c4fea9119..6f3c673547f 100644
--- a/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_multi_stmt_txn.yml
+++ b/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_multi_stmt_txn.yml
@@ -115,9 +115,7 @@ selector:
# router tries to commit, it may not know the full participant list.
- jstests/concurrency/fsm_workloads/multi_statement_transaction_all_commands_same_session.js
- # TODO SERVER-38190: Killing an operation committing a prepared txn can crash.
# TODO SERVER-38297: Killing session on a secondary applying a prepare oplog entry can crash.
- # TODO SERVER-38299: Killing an operation preparing a transaction can crash.
- jstests/concurrency/fsm_workloads/multi_statement_transaction_kill_sessions_atomicity_isolation.js
##
diff --git a/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_multi_stmt_txn_with_balancer.yml b/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_multi_stmt_txn_with_balancer.yml
index dedebb659a7..9f689090daf 100644
--- a/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_multi_stmt_txn_with_balancer.yml
+++ b/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_multi_stmt_txn_with_balancer.yml
@@ -115,9 +115,7 @@ selector:
# router tries to commit, it may not know the full participant list.
- jstests/concurrency/fsm_workloads/multi_statement_transaction_all_commands_same_session.js
- # TODO SERVER-38190: Killing an operation committing a prepared txn can crash.
# TODO SERVER-38297: Killing session on a secondary applying a prepare oplog entry can crash.
- # TODO SERVER-38299: Killing an operation preparing a transaction can crash.
- jstests/concurrency/fsm_workloads/multi_statement_transaction_kill_sessions_atomicity_isolation.js
# Expects reads to die with a particular error, but other errors are possible if the read is part
diff --git a/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_with_balancer.yml b/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_with_balancer.yml
index c34499279f1..62894e1f031 100644
--- a/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_with_balancer.yml
+++ b/buildscripts/resmokeconfig/suites/concurrency_sharded_replication_with_balancer.yml
@@ -115,12 +115,8 @@ selector:
# router tries to commit, it may not know the full participant list.
- jstests/concurrency/fsm_workloads/multi_statement_transaction_all_commands_same_session.js
- # TODO SERVER-38190: Killing an operation committing a prepared txn can crash.
# TODO SERVER-38297: Killing session on a secondary applying a prepare oplog entry can crash.
- # TODO SERVER-38299: Killing an operation preparing a transaction can crash.
- jstests/concurrency/fsm_workloads/multi_statement_transaction_kill_sessions_atomicity_isolation.js
- - jstests/concurrency/fsm_workloads/snapshot_read_kill_op_only.js
- - jstests/concurrency/fsm_workloads/snapshot_read_kill_operations.js
exclude_with_any_tags:
- assumes_balancer_off
diff --git a/jstests/concurrency/fsm_workload_helpers/cleanup_txns.js b/jstests/concurrency/fsm_workload_helpers/cleanup_txns.js
index df44058f36b..c3e135c98d5 100644
--- a/jstests/concurrency/fsm_workload_helpers/cleanup_txns.js
+++ b/jstests/concurrency/fsm_workload_helpers/cleanup_txns.js
@@ -11,13 +11,14 @@ function abortTransaction(sessionAwareDB, txnNumber, errorCodes) {
// Don't use the given session as it might be in a state we don't want to be and
// because we are trying to abort with arbitrary txnNumber.
let rawDB = sessionAwareDB.getSession().getClient().getDB(sessionAwareDB.getName());
- const res = rawDB.adminCommand({
+
+ const abortCmd = {
abortTransaction: 1,
lsid: sessionAwareDB.getSession().getSessionId(),
txnNumber: NumberLong(txnNumber),
autocommit: false
- });
-
+ };
+ const res = rawDB.adminCommand(abortCmd);
return assert.commandWorkedOrFailedWithCode(res, errorCodes, () => `cmd: ${tojson(abortCmd)}`);
}
diff --git a/jstests/concurrency/fsm_workload_helpers/snapshot_read_utils.js b/jstests/concurrency/fsm_workload_helpers/snapshot_read_utils.js
index a020855727b..8662e4f945e 100644
--- a/jstests/concurrency/fsm_workload_helpers/snapshot_read_utils.js
+++ b/jstests/concurrency/fsm_workload_helpers/snapshot_read_utils.js
@@ -83,7 +83,6 @@ function doSnapshotGetMore(collName, data, getMoreErrorCodes, commitTransactionE
const commitCmd = {
commitTransaction: 1,
txnNumber: NumberLong(data.txnNumber),
- stmtId: NumberInt(data.stmtId++),
autocommit: false
};
res = data.sessionDb.adminCommand(commitCmd);
diff --git a/jstests/concurrency/fsm_workloads/multi_statement_transaction_atomicity_isolation.js b/jstests/concurrency/fsm_workloads/multi_statement_transaction_atomicity_isolation.js
index 72cab1d2ffe..89ac177ad1c 100644
--- a/jstests/concurrency/fsm_workloads/multi_statement_transaction_atomicity_isolation.js
+++ b/jstests/concurrency/fsm_workloads/multi_statement_transaction_atomicity_isolation.js
@@ -35,6 +35,7 @@
* (b) transaction C's (tid, txnNumber, numToUpdate) element doesn't appear numToUpdate times
* across a consistent snapshot of all of the documents. This would suggest that the database
* failed to atomically update all documents modified in a concurrent transaction.
+ *
* (c) transaction D's (tid, txnNumber) for a given (docId, dbName, collName) doesn't match the
* (tid, txnNumber) for the thread with threadId == tid. This indicates that there are writes
* that exist in the database that were not committed.
diff --git a/jstests/concurrency/fsm_workloads/snapshot_read_kill_operations.js b/jstests/concurrency/fsm_workloads/snapshot_read_kill_operations.js
index ca5afd928c3..6a68f7d93ad 100644
--- a/jstests/concurrency/fsm_workloads/snapshot_read_kill_operations.js
+++ b/jstests/concurrency/fsm_workloads/snapshot_read_kill_operations.js
@@ -6,7 +6,9 @@
*
* @tags: [uses_transactions, state_functions_share_transaction]
*/
+
load('jstests/concurrency/fsm_workload_helpers/snapshot_read_utils.js');
+
var $config = (function() {
const data = {numIds: 100, batchSize: 50};
@@ -24,11 +26,12 @@ var $config = (function() {
snapshotFind: function snapshotFind(db, collName) {
const sortByAscending = false;
- doSnapshotFind(
- sortByAscending,
- collName,
- this,
- [ErrorCodes.NoSuchTransaction, ErrorCodes.LockTimeout, ErrorCodes.Interrupted]);
+ doSnapshotFind(sortByAscending, collName, this, [
+ ErrorCodes.NoSuchTransaction,
+ ErrorCodes.LockTimeout,
+ ErrorCodes.Interrupted,
+ ErrorCodes.SnapshotTooOld,
+ ]);
},
snapshotGetMore: function snapshotGetMore(db, collName) {
diff --git a/src/mongo/s/transaction_router.cpp b/src/mongo/s/transaction_router.cpp
index 1d2b64cdb6c..367ff5cacd0 100644
--- a/src/mongo/s/transaction_router.cpp
+++ b/src/mongo/s/transaction_router.cpp
@@ -674,8 +674,15 @@ Shard::CommandResponse TransactionRouter::commitTransaction(
return _commitWithRecoveryToken(opCtx, *recoveryToken);
}
- uassert(
- ErrorCodes::IllegalOperation, "Cannot commit without participants", !_participants.empty());
+ if (_participants.empty()) {
+ // The participants list can be empty if a transaction was began on mongos, but it never
+ // ended up targeting any hosts. Such cases are legal for example if a find is issued
+ // against a non-existend database.
+ uassert(ErrorCodes::IllegalOperation,
+ "Cannot commit without participants",
+ _txnNumber != kUninitializedTxnNumber);
+ return {boost::none, BSON("ok" << true), Status::OK(), Status::OK()};
+ }
if (_participants.size() == 1) {
return _commitSingleShardTransaction(opCtx);
diff --git a/src/mongo/s/transaction_router.h b/src/mongo/s/transaction_router.h
index b53a27c0ece..983ad8ba4d4 100644
--- a/src/mongo/s/transaction_router.h
+++ b/src/mongo/s/transaction_router.h
@@ -315,7 +315,8 @@ private:
*/
void _verifyParticipantAtClusterTime(const Participant& participant);
- // The currently active transaction number on this transaction router (i.e. on the session)
+ // The currently active transaction number on this router, if beginOrContinueTxn has been
+ // called. Otherwise set to kUninitializedTxnNumber.
TxnNumber _txnNumber{kUninitializedTxnNumber};
// Whether the router has initiated a two-phase commit by handing off commit coordination to the