summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/concurrency/fsm_workload_helpers/auto_retry_transaction.js17
-rw-r--r--jstests/core/txns/multi_statement_transaction_write_error.js3
-rw-r--r--jstests/multiVersion/update_shard_key_disallowed_fcv40.js6
-rw-r--r--jstests/noPassthrough/change_stream_transaction.js4
-rw-r--r--jstests/noPassthrough/exchange_in_session.js2
-rw-r--r--jstests/noPassthrough/server_transaction_metrics_for_prepared_transactions.js2
-rw-r--r--jstests/replsets/initial_sync_test_fixture_test.js4
-rw-r--r--jstests/sharding/change_stream_transaction_sharded.js2
-rw-r--r--jstests/sharding/transactions_error_labels.js6
-rw-r--r--jstests/sharding/txn_agg.js2
-rw-r--r--jstests/sharding/unsharded_lookup_in_txn.js2
11 files changed, 28 insertions, 22 deletions
diff --git a/jstests/concurrency/fsm_workload_helpers/auto_retry_transaction.js b/jstests/concurrency/fsm_workload_helpers/auto_retry_transaction.js
index f8a1dcdabae..43bdc7ea8a8 100644
--- a/jstests/concurrency/fsm_workload_helpers/auto_retry_transaction.js
+++ b/jstests/concurrency/fsm_workload_helpers/auto_retry_transaction.js
@@ -145,14 +145,15 @@ var {withTxnAndAutoRetry, isKilledSessionCode} = (function() {
} catch (e) {
if (!hasCommitTxnError) {
- // Use the version of abortTransaction() that ignores errors. We ignore the
- // error from abortTransaction because the transaction may have implicitly
- // been aborted by the server already and will therefore return a
- // NoSuchTransaction error response.
- // We need to call abortTransaction() in order to update the mongo shell's
- // state such that it agrees no transaction is currently in progress on this
- // session.
- session.abortTransaction();
+ // We need to call abortTransaction_forTesting() in order to update the mongo
+ // shell's state such that it agrees no transaction is currently in progress on
+ // this session.
+ // The transaction may have implicitly been aborted by the server or killed by
+ // the kill_session helper and will therefore return a
+ // NoSuchTransaction/Interrupted error code.
+ assert.commandWorkedOrFailedWithCode(
+ session.abortTransaction_forTesting(),
+ [ErrorCodes.NoSuchTransaction, ErrorCodes.Interrupted]);
}
if (shouldRetryEntireTxnOnError(e, hasCommitTxnError, retryOnKilledSession)) {
diff --git a/jstests/core/txns/multi_statement_transaction_write_error.js b/jstests/core/txns/multi_statement_transaction_write_error.js
index 293d28d93e5..c8828a2d735 100644
--- a/jstests/core/txns/multi_statement_transaction_write_error.js
+++ b/jstests/core/txns/multi_statement_transaction_write_error.js
@@ -40,7 +40,8 @@
throw e;
}
} finally {
- session.abortTransaction();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
}
}
diff --git a/jstests/multiVersion/update_shard_key_disallowed_fcv40.js b/jstests/multiVersion/update_shard_key_disallowed_fcv40.js
index 7bf01243d5f..ee7648679ab 100644
--- a/jstests/multiVersion/update_shard_key_disallowed_fcv40.js
+++ b/jstests/multiVersion/update_shard_key_disallowed_fcv40.js
@@ -127,13 +127,15 @@
// both modify and replacement updates
session.startTransaction();
assert.writeError(sessionDB.foo.update({x: 80}, {$set: {x: 100}}));
- session.abortTransaction();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
session.startTransaction();
assert.throws(function() {
sessionDB.foo.findAndModify({query: {x: 80}, update: {x: 100}});
});
- session.abortTransaction();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
mongos.getDB(kDbName).foo.drop();
diff --git a/jstests/noPassthrough/change_stream_transaction.js b/jstests/noPassthrough/change_stream_transaction.js
index 790eb7c3756..801eab6f0a0 100644
--- a/jstests/noPassthrough/change_stream_transaction.js
+++ b/jstests/noPassthrough/change_stream_transaction.js
@@ -151,7 +151,7 @@
assertNoChanges(changeStreamCursor);
// Transition the second transaction to prepared. We skip capturing the prepare
- // timestamp it is not required for abortTransaction().
+ // timestamp it is not required for abortTransaction_forTesting().
PrepareHelpers.prepareTransaction(session2);
assertNoChanges(changeStreamCursor);
@@ -164,7 +164,7 @@
//
// Abort second transaction.
//
- session2.abortTransaction();
+ assert.commandWorked(session2.abortTransaction_forTesting());
assertWriteVisibleWithCapture(
changeStreamCursor, "insert", {_id: "no-txn-doc-4"}, changeList);
assertNoChanges(changeStreamCursor);
diff --git a/jstests/noPassthrough/exchange_in_session.js b/jstests/noPassthrough/exchange_in_session.js
index dd201f555f8..20261c0c081 100644
--- a/jstests/noPassthrough/exchange_in_session.js
+++ b/jstests/noPassthrough/exchange_in_session.js
@@ -79,7 +79,7 @@
return true;
});
- session.abortTransaction();
+ assert.commandWorked(session.abortTransaction_forTesting());
st.stop();
})();
diff --git a/jstests/noPassthrough/server_transaction_metrics_for_prepared_transactions.js b/jstests/noPassthrough/server_transaction_metrics_for_prepared_transactions.js
index 81ec147934a..36ba6b0a9d6 100644
--- a/jstests/noPassthrough/server_transaction_metrics_for_prepared_transactions.js
+++ b/jstests/noPassthrough/server_transaction_metrics_for_prepared_transactions.js
@@ -157,7 +157,7 @@
// Verify the total prepared and aborted transaction counters are updated after an abort and the
// current prepared counter is decremented.
- session.abortTransaction();
+ assert.commandWorked(session.abortTransaction_forTesting());
newStatus = assert.commandWorked(testDB.adminCommand({serverStatus: 1}));
verifyServerStatusFields(newStatus);
verifyServerStatusChange(
diff --git a/jstests/replsets/initial_sync_test_fixture_test.js b/jstests/replsets/initial_sync_test_fixture_test.js
index 5a87dcfd983..520ba43b2b4 100644
--- a/jstests/replsets/initial_sync_test_fixture_test.js
+++ b/jstests/replsets/initial_sync_test_fixture_test.js
@@ -159,7 +159,7 @@
assert(initialSyncTest.step(), "Expected initial sync to have completed, but it did not");
// Abort transaction so that the data consistency checks in stop() can run.
- session.abortTransaction();
+ assert.commandWorked(session.abortTransaction_forTesting());
// Issue a w:2 write to make sure the secondary has replicated the abortTransaction oplog entry.
assert.commandWorked(primary.getDB("otherDB").otherColl.insert({x: 1}, {writeConcern: {w: 2}}));
@@ -174,4 +174,4 @@
// Do data consistency checks at the end.
initialSyncTest.stop();
-})(); \ No newline at end of file
+})();
diff --git a/jstests/sharding/change_stream_transaction_sharded.js b/jstests/sharding/change_stream_transaction_sharded.js
index cdc7b0006be..919b7aa95f9 100644
--- a/jstests/sharding/change_stream_transaction_sharded.js
+++ b/jstests/sharding/change_stream_transaction_sharded.js
@@ -183,7 +183,7 @@
// Abort second transaction and confirm that the change stream sees only the previous
// non-transaction write.
- session2.abortTransaction();
+ assert.commandWorked(session2.abortTransaction_forTesting());
assertWritesVisibleWithCapture(changeStreamCursor,
[],
[{operationType: "insert", _id: "no-txn-doc-4"}],
diff --git a/jstests/sharding/transactions_error_labels.js b/jstests/sharding/transactions_error_labels.js
index d0b4188c1a7..755f2120167 100644
--- a/jstests/sharding/transactions_error_labels.js
+++ b/jstests/sharding/transactions_error_labels.js
@@ -172,7 +172,8 @@
res = startTransaction(mongosSession, dbName, collName);
checkMongosResponse(res, ErrorCodes.WriteConflict, "TransientTransactionError", null);
turnOffFailCommand(st.rs0);
- mongosSession.abortTransaction();
+ assert.commandFailedWithCode(mongosSession.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
// statements prior to commit network error
failCommandWithError(
@@ -181,7 +182,8 @@
res = startTransaction(mongosSession, dbName, collName);
checkMongosResponse(res, ErrorCodes.HostUnreachable, "TransientTransactionError", null);
turnOffFailCommand(st.rs0);
- mongosSession.abortTransaction();
+ assert.commandFailedWithCode(mongosSession.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
// commitTransaction for single-shard transaction (mongos sends commitTransaction)
runCommitTests("commitTransaction");
diff --git a/jstests/sharding/txn_agg.js b/jstests/sharding/txn_agg.js
index 9768ef41421..635aaf8ca83 100644
--- a/jstests/sharding/txn_agg.js
+++ b/jstests/sharding/txn_agg.js
@@ -84,7 +84,7 @@
));
assert.eq(err.code, ErrorCodes.InvalidOptions, err);
- session.abortTransaction();
+ assert.commandWorked(session.abortTransaction_forTesting());
// Insert some data outside of a transaction.
assert.commandWorked(sessionColl.insert([{_id: -1}, {_id: 0}, {_id: 1}]));
diff --git a/jstests/sharding/unsharded_lookup_in_txn.js b/jstests/sharding/unsharded_lookup_in_txn.js
index 620052a634f..32d0d21e105 100644
--- a/jstests/sharding/unsharded_lookup_in_txn.js
+++ b/jstests/sharding/unsharded_lookup_in_txn.js
@@ -76,7 +76,7 @@
assert.eq(doc.matches.length, kUnshardedCollOriginalSize);
}
- session.abortTransaction();
+ assert.commandWorked(session.abortTransaction_forTesting());
};
// Run the test once, with all of the data on shard 1. This means that the merging shard (shard