summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/core/txns/abort_prepared_transaction.js6
-rw-r--r--jstests/core/txns/commit_prepared_transaction_errors.js5
-rw-r--r--jstests/core/txns/disallow_operations_on_prepared_transaction.js6
-rw-r--r--jstests/core/txns/empty_prepare.js7
-rw-r--r--jstests/core/txns/ensure_active_txn_for_prepare_transaction.js2
-rw-r--r--jstests/core/txns/libs/prepare_helpers.js5
-rw-r--r--jstests/core/txns/multi_statement_transaction_using_api.js2
-rw-r--r--jstests/core/txns/no_new_transactions_when_prepared_transaction_in_progress.js2
-rw-r--r--jstests/core/txns/no_writes_to_config_transactions_with_prepared_transaction.js2
-rw-r--r--jstests/core/txns/prepare_conflict.js2
-rw-r--r--jstests/core/txns/prepare_conflict_aggregation_behavior.js2
-rw-r--r--jstests/core/txns/prepare_nonexistent_transaction.js6
-rw-r--r--jstests/core/txns/prepare_prepared_transaction.js2
-rw-r--r--jstests/core/txns/prepare_requires_fcv42.js3
-rw-r--r--jstests/core/txns/prepare_transaction_unique_index_conflict.js4
-rw-r--r--jstests/core/txns/shell_prompt_in_transaction.js2
-rw-r--r--jstests/core/txns/transaction_error_handling.js16
-rw-r--r--jstests/core/txns/write_conflicts_with_non_txns.js2
-rw-r--r--jstests/noPassthrough/global_transaction_latency_histogram.js4
-rw-r--r--jstests/noPassthrough/readConcern_atClusterTime_snapshot_selection.js3
-rw-r--r--jstests/noPassthrough/readConcern_snapshot_mongos.js5
-rw-r--r--jstests/noPassthrough/server_transaction_metrics.js2
-rw-r--r--jstests/replsets/dbhash_read_at_cluster_time.js2
-rw-r--r--jstests/replsets/ddl_ops_after_prepare_lock_failpoint.js2
-rw-r--r--jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp_no_oplog_application.js2
-rw-r--r--jstests/replsets/inmemory_preserves_active_txns.js2
-rw-r--r--jstests/replsets/prepare_conflict_read_concern_behavior.js16
-rw-r--r--jstests/replsets/recover_committed_aborted_prepared_transactions.js4
-rw-r--r--jstests/replsets/recover_prepared_transaction_state.js2
-rw-r--r--jstests/replsets/recovery_preserves_active_txns.js2
-rw-r--r--jstests/replsets/rollback_aborted_prepared_transaction.js2
-rw-r--r--jstests/replsets/rollover_preserves_active_txns.js2
-rw-r--r--jstests/replsets/transactions_only_allowed_on_primaries.js3
-rw-r--r--jstests/replsets/transient_txn_error_labels.js16
-rw-r--r--jstests/sharding/libs/update_shard_key_helpers.js20
-rw-r--r--jstests/sharding/transactions_targeting_errors.js6
-rw-r--r--jstests/sharding/txn_agg.js6
-rw-r--r--jstests/sharding/update_shard_key_doc_moves_shards.js7
38 files changed, 106 insertions, 78 deletions
diff --git a/jstests/core/txns/abort_prepared_transaction.js b/jstests/core/txns/abort_prepared_transaction.js
index 1907d92f216..365a4d852bf 100644
--- a/jstests/core/txns/abort_prepared_transaction.js
+++ b/jstests/core/txns/abort_prepared_transaction.js
@@ -33,7 +33,7 @@
assert.eq(doc1, sessionColl.findOne(doc1));
PrepareHelpers.prepareTransaction(session);
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
// After abort the insert is rolled back.
assert.eq(null, testColl.findOne(doc1));
@@ -55,7 +55,7 @@
assert.eq(doc2, sessionColl.findOne(doc2));
PrepareHelpers.prepareTransaction(session);
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
// After abort the update is rolled back.
assert.eq(doc1, testColl.findOne({_id: 1}));
@@ -75,7 +75,7 @@
assert.eq(null, sessionColl.findOne(doc2));
PrepareHelpers.prepareTransaction(session);
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
// After abort the delete is rolled back.
assert.eq(doc2, testColl.findOne(doc2));
diff --git a/jstests/core/txns/commit_prepared_transaction_errors.js b/jstests/core/txns/commit_prepared_transaction_errors.js
index f8f5e27dc6e..97ecd5bf8e9 100644
--- a/jstests/core/txns/commit_prepared_transaction_errors.js
+++ b/jstests/core/txns/commit_prepared_transaction_errors.js
@@ -33,9 +33,10 @@
assert.commandFailedWithCode(
anotherSession.getDatabase(dbName).getCollection(collName).insert(doc),
ErrorCodes.WriteConflict);
- anotherSession.abortTransaction_forTesting();
+ assert.commandFailedWithCode(anotherSession.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
// Abort the original transaction.
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
jsTestLog("Test committing a prepared transaction with an invalid 'commitTimestamp'.");
session.startTransaction();
diff --git a/jstests/core/txns/disallow_operations_on_prepared_transaction.js b/jstests/core/txns/disallow_operations_on_prepared_transaction.js
index dcb924e89e8..6263c4d6ccb 100644
--- a/jstests/core/txns/disallow_operations_on_prepared_transaction.js
+++ b/jstests/core/txns/disallow_operations_on_prepared_transaction.js
@@ -28,7 +28,7 @@
let firstTimestamp = PrepareHelpers.prepareTransaction(session);
let secondTimestamp = PrepareHelpers.prepareTransaction(session);
assert.eq(firstTimestamp, secondTimestamp);
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
jsTestLog("Test that you can call commitTransaction on a prepared transaction.");
session.startTransaction();
@@ -110,7 +110,7 @@
res = assert.commandFailedWithCode(sessionColl.update({_id: 4}, {a: 1}),
ErrorCodes.PreparedTransactionInProgress);
assert.eq(res.errorLabels, ["TransientTransactionError"]);
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
jsTestLog("Test that you can't run getMore on a prepared transaction.");
session.startTransaction();
@@ -126,7 +126,7 @@
assert.commandFailedWithCode(
sessionDB.runCommand({killCursors: collName, cursors: [res.cursor.id]}),
ErrorCodes.PreparedTransactionInProgress);
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
session.endSession();
}());
diff --git a/jstests/core/txns/empty_prepare.js b/jstests/core/txns/empty_prepare.js
index e0811329585..cb1b616c9fc 100644
--- a/jstests/core/txns/empty_prepare.js
+++ b/jstests/core/txns/empty_prepare.js
@@ -26,7 +26,8 @@
session.startTransaction();
assert.commandFailedWithCode(sessionDB.adminCommand({prepareTransaction: 1}),
ErrorCodes.OperationNotSupportedInTransaction);
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
// ---- Test 2. Only reads before prepare ----
@@ -35,7 +36,7 @@
let res = assert.commandWorked(sessionDB.adminCommand({prepareTransaction: 1}));
// Makes sure prepareTransaction returns prepareTimestamp in its response.
assert(res.hasOwnProperty("prepareTimestamp"), tojson(res));
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
// ---- Test 3. Noop writes before prepare ----
@@ -47,6 +48,6 @@
res = assert.commandWorked(sessionDB.adminCommand({prepareTransaction: 1}));
// Makes sure prepareTransaction returns prepareTimestamp in its response.
assert(res.hasOwnProperty("prepareTimestamp"), tojson(res));
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
}());
diff --git a/jstests/core/txns/ensure_active_txn_for_prepare_transaction.js b/jstests/core/txns/ensure_active_txn_for_prepare_transaction.js
index f3281332b7a..bd703a1d7f1 100644
--- a/jstests/core/txns/ensure_active_txn_for_prepare_transaction.js
+++ b/jstests/core/txns/ensure_active_txn_for_prepare_transaction.js
@@ -34,7 +34,7 @@
"Test that we can't call prepareTransaction if the most recent transaction was aborted");
session.startTransaction();
assert.commandWorked(sessionColl.insert({_id: 1}));
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
assert.commandFailedWithCode(sessionDB.adminCommand({
prepareTransaction: 1,
diff --git a/jstests/core/txns/libs/prepare_helpers.js b/jstests/core/txns/libs/prepare_helpers.js
index 0f8f346a6bb..9fca9e20cfc 100644
--- a/jstests/core/txns/libs/prepare_helpers.js
+++ b/jstests/core/txns/libs/prepare_helpers.js
@@ -40,9 +40,10 @@ const PrepareHelpers = (function() {
// End the transaction on the shell session.
if (res.ok) {
- session.commitTransaction_forTesting();
+ assert.commandWorked(session.commitTransaction_forTesting());
} else {
- session.abortTransaction_forTesting();
+ assert.commandWorkedOrFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
}
return res;
}
diff --git a/jstests/core/txns/multi_statement_transaction_using_api.js b/jstests/core/txns/multi_statement_transaction_using_api.js
index c598318aec8..6701897f651 100644
--- a/jstests/core/txns/multi_statement_transaction_using_api.js
+++ b/jstests/core/txns/multi_statement_transaction_using_api.js
@@ -24,7 +24,7 @@
session.startTransaction({readConcern: {level: "snapshot"}, writeConcern: {w: "majority"}});
// Successfully call abortTransaction.
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
//
// Test that calling commitTransaction as the first statement in a transaction is allowed and
diff --git a/jstests/core/txns/no_new_transactions_when_prepared_transaction_in_progress.js b/jstests/core/txns/no_new_transactions_when_prepared_transaction_in_progress.js
index b15ab5fa462..2aa272a0d2b 100644
--- a/jstests/core/txns/no_new_transactions_when_prepared_transaction_in_progress.js
+++ b/jstests/core/txns/no_new_transactions_when_prepared_transaction_in_progress.js
@@ -49,7 +49,7 @@
autocommit: false
}),
ErrorCodes.NoSuchTransaction);
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
session.endSession();
}());
diff --git a/jstests/core/txns/no_writes_to_config_transactions_with_prepared_transaction.js b/jstests/core/txns/no_writes_to_config_transactions_with_prepared_transaction.js
index 9a450c2c9f0..3c909583cfe 100644
--- a/jstests/core/txns/no_writes_to_config_transactions_with_prepared_transaction.js
+++ b/jstests/core/txns/no_writes_to_config_transactions_with_prepared_transaction.js
@@ -94,7 +94,7 @@
{abortTransaction: 1, txnNumber: NumberLong(0), stmtid: NumberInt(2), autocommit: false}));
session.endSession();
- session2.abortTransaction_forTesting();
+ assert.commandWorked(session2.abortTransaction_forTesting());
session2.endSession();
}());
diff --git a/jstests/core/txns/prepare_conflict.js b/jstests/core/txns/prepare_conflict.js
index e1417e3966f..36c2a22fefc 100644
--- a/jstests/core/txns/prepare_conflict.js
+++ b/jstests/core/txns/prepare_conflict.js
@@ -88,7 +88,7 @@
.runCommand({find: TestData.collName, filter: {_id: TestData.txnDoc._id}});
}, db.getMongo().port);
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
// The find command should be successful.
findAwait({checkExitSuccess: true});
diff --git a/jstests/core/txns/prepare_conflict_aggregation_behavior.js b/jstests/core/txns/prepare_conflict_aggregation_behavior.js
index 5aed15c15d9..37c9984d042 100644
--- a/jstests/core/txns/prepare_conflict_aggregation_behavior.js
+++ b/jstests/core/txns/prepare_conflict_aggregation_behavior.js
@@ -46,7 +46,7 @@
// prepared transaction.
assert.eq([{_id: 0}, {_id: 1, b: 1}], outColl.find().toArray());
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
session.startTransaction();
assert.commandWorked(sessionOutColl.update({_id: 1}, {_id: 1, a: 1}));
prepareTimestamp = PrepareHelpers.prepareTransaction(session);
diff --git a/jstests/core/txns/prepare_nonexistent_transaction.js b/jstests/core/txns/prepare_nonexistent_transaction.js
index 20f2a51a2a7..40e0b540354 100644
--- a/jstests/core/txns/prepare_nonexistent_transaction.js
+++ b/jstests/core/txns/prepare_nonexistent_transaction.js
@@ -38,11 +38,11 @@
autocommit: false
}),
ErrorCodes.NoSuchTransaction);
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
session.startTransaction();
assert.commandWorked(sessionColl.insert(doc));
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
jsTestLog("Test that if there is no transaction active on the current session, the " +
"'txnNumber' given matches the last known transaction for this session and the " +
"last known transaction was aborted then it errors with 'NoSuchTransaction'.");
@@ -62,7 +62,7 @@
sessionDB.adminCommand(
{prepareTransaction: 1, txnNumber: NumberLong(0), autocommit: false}),
ErrorCodes.TransactionTooOld);
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
jsTestLog("Test that if there is no transaction active on the current session and the " +
"'txnNumber' given is less than the current transaction, errors with " +
diff --git a/jstests/core/txns/prepare_prepared_transaction.js b/jstests/core/txns/prepare_prepared_transaction.js
index 52617a9d83e..8032e885e3e 100644
--- a/jstests/core/txns/prepare_prepared_transaction.js
+++ b/jstests/core/txns/prepare_prepared_transaction.js
@@ -31,7 +31,7 @@
const secondTimestamp = PrepareHelpers.prepareTransaction(session);
// Both prepareTimestamps should be equal.
assert.eq(firstTimestamp, secondTimestamp);
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
session.endSession();
}());
diff --git a/jstests/core/txns/prepare_requires_fcv42.js b/jstests/core/txns/prepare_requires_fcv42.js
index e7147aa13c6..a7be765a969 100644
--- a/jstests/core/txns/prepare_requires_fcv42.js
+++ b/jstests/core/txns/prepare_requires_fcv42.js
@@ -38,7 +38,8 @@
assert.commandFailedWithCode(sessionDB.adminCommand({prepareTransaction: 1}),
ErrorCodes.CommandNotSupported);
// Abort the transaction in the shell.
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
} finally {
jsTestLog("Restore the original featureCompatibilityVersion.");
diff --git a/jstests/core/txns/prepare_transaction_unique_index_conflict.js b/jstests/core/txns/prepare_transaction_unique_index_conflict.js
index db6c370d8c2..e364a1e0a0e 100644
--- a/jstests/core/txns/prepare_transaction_unique_index_conflict.js
+++ b/jstests/core/txns/prepare_transaction_unique_index_conflict.js
@@ -40,5 +40,5 @@
testDB.runCommand({insert: collName, documents: [{_id: 3, a: 1}], maxTimeMS: 5000}),
ErrorCodes.MaxTimeMSExpired);
- session.abortTransaction_forTesting();
-})(); \ No newline at end of file
+ assert.commandWorked(session.abortTransaction_forTesting());
+})();
diff --git a/jstests/core/txns/shell_prompt_in_transaction.js b/jstests/core/txns/shell_prompt_in_transaction.js
index 01242ea586f..a149155de83 100644
--- a/jstests/core/txns/shell_prompt_in_transaction.js
+++ b/jstests/core/txns/shell_prompt_in_transaction.js
@@ -26,7 +26,7 @@
assert.commandWorked(coll.insert(doc));
assert.docEq(doc, coll.findOne());
simulatePrompt();
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
assert.docEq(null, coll.findOne());
// Start a transaction, so the session has a running transaction now.
diff --git a/jstests/core/txns/transaction_error_handling.js b/jstests/core/txns/transaction_error_handling.js
index 15c3d763330..027199bef03 100644
--- a/jstests/core/txns/transaction_error_handling.js
+++ b/jstests/core/txns/transaction_error_handling.js
@@ -25,7 +25,8 @@
}
try {
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
} catch (e) {
assert.eq(e.message, "There is no active transaction to abort on this session.");
}
@@ -59,7 +60,8 @@
jsTestLog("Test that we cannot abort a transaction that has already been committed");
// We cannot call abortTransaction on a transaction that has already been committed.
try {
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
} catch (e) {
assert.eq(e.message, "Cannot call abortTransaction after calling commitTransaction.");
}
@@ -68,7 +70,7 @@
// abortTransaction on a transaction that is in the 'aborted' state.
session.startTransaction();
assert.commandWorked(sessionColl.insert({_id: "insert-2"}));
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
jsTestLog("Test that we cannot commit a transaction that has already been aborted.");
// We cannot call commitTransaction on a transaction that has already been aborted.
@@ -81,7 +83,8 @@
jsTestLog("Test that we cannot abort a transaction that has already been aborted.");
// We also cannot call abortTransaction on a transaction that has already been aborted.
try {
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
} catch (e) {
assert.eq(e.message, "Cannot call abortTransaction twice.");
}
@@ -105,11 +108,12 @@
session.startTransaction();
assert.commandWorked(sessionColl.insert({_id: "insert-4"}));
// The transaction state should be changed to 'aborted'.
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
// The transaction state should be changed to 'inactive'.
assert.commandWorked(sessionColl.insert({_id: "normal-insert-2"}));
try {
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
} catch (e) {
assert.eq(e.message, "There is no active transaction to abort on this session.");
}
diff --git a/jstests/core/txns/write_conflicts_with_non_txns.js b/jstests/core/txns/write_conflicts_with_non_txns.js
index c198c85084c..99037458ff4 100644
--- a/jstests/core/txns/write_conflicts_with_non_txns.js
+++ b/jstests/core/txns/write_conflicts_with_non_txns.js
@@ -114,7 +114,7 @@
// Abort the transaction, which should allow the single document write to finish and insert its
// document successfully.
jsTestLog("Abort the multi-document transaction.");
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
thread.join();
assert.commandWorked(thread.returnData());
diff --git a/jstests/noPassthrough/global_transaction_latency_histogram.js b/jstests/noPassthrough/global_transaction_latency_histogram.js
index eef213dc3d4..8883ea015ff 100644
--- a/jstests/noPassthrough/global_transaction_latency_histogram.js
+++ b/jstests/noPassthrough/global_transaction_latency_histogram.js
@@ -89,7 +89,7 @@
// towards the "commands" counter.
session.startTransaction();
assert.commandWorked(sessionColl.insert({_id: "insert-2"}));
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
lastHistogram = checkHistogramDiff(lastHistogram,
getHistogramStats(),
{"reads": 0, "writes": 1, "commands": 2, "transactions": 1});
@@ -117,4 +117,4 @@
session.endSession();
rst.stopSet();
-}()); \ No newline at end of file
+}());
diff --git a/jstests/noPassthrough/readConcern_atClusterTime_snapshot_selection.js b/jstests/noPassthrough/readConcern_atClusterTime_snapshot_selection.js
index d631d95acdd..afb1dae1f0a 100644
--- a/jstests/noPassthrough/readConcern_atClusterTime_snapshot_selection.js
+++ b/jstests/noPassthrough/readConcern_atClusterTime_snapshot_selection.js
@@ -89,7 +89,8 @@
primarySession.startTransaction(
{readConcern: {level: "snapshot", atClusterTime: Timestamp(1, 1)}});
assert.commandFailedWithCode(primaryDB.runCommand({find: collName}), ErrorCodes.SnapshotTooOld);
- primarySession.abortTransaction_forTesting();
+ assert.commandFailedWithCode(primarySession.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
rst.stopSet();
}());
diff --git a/jstests/noPassthrough/readConcern_snapshot_mongos.js b/jstests/noPassthrough/readConcern_snapshot_mongos.js
index 7427a5669f5..74a2e6e0ffe 100644
--- a/jstests/noPassthrough/readConcern_snapshot_mongos.js
+++ b/jstests/noPassthrough/readConcern_snapshot_mongos.js
@@ -10,7 +10,7 @@
function expectSuccessInTxnThenAbort(session, sessionConn, cmdObj) {
session.startTransaction();
assert.commandWorked(sessionConn.runCommand(cmdObj));
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
}
// Runs the command as the first in a multi statement txn that is aborted right after, expecting
@@ -18,7 +18,8 @@
function expectFailInTxnThenAbort(session, sessionConn, expectedErrorCode, cmdObj) {
session.startTransaction();
assert.commandFailedWithCode(sessionConn.runCommand(cmdObj), expectedErrorCode);
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
}
const dbName = "test";
diff --git a/jstests/noPassthrough/server_transaction_metrics.js b/jstests/noPassthrough/server_transaction_metrics.js
index a3d870f8a50..35581f5ac2f 100644
--- a/jstests/noPassthrough/server_transaction_metrics.js
+++ b/jstests/noPassthrough/server_transaction_metrics.js
@@ -112,7 +112,7 @@
initialStatus.transactions, newStatus.transactions, "currentInactive", 1);
// Compare server status after the transaction abort with the server status before.
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
newStatus = assert.commandWorked(testDB.adminCommand({serverStatus: 1}));
verifyServerStatusFields(newStatus);
verifyServerStatusChange(initialStatus.transactions, newStatus.transactions, "totalStarted", 2);
diff --git a/jstests/replsets/dbhash_read_at_cluster_time.js b/jstests/replsets/dbhash_read_at_cluster_time.js
index 252b5004004..bf7995aade6 100644
--- a/jstests/replsets/dbhash_read_at_cluster_time.js
+++ b/jstests/replsets/dbhash_read_at_cluster_time.js
@@ -96,7 +96,7 @@
res = assert.commandFailedWithCode(db.runCommand({dbHash: 1, maxTimeMS: 1000}),
ErrorCodes.MaxTimeMSExpired);
- otherSession.abortTransaction_forTesting();
+ assert.commandWorked(otherSession.abortTransaction_forTesting());
otherSession.endSession();
}
diff --git a/jstests/replsets/ddl_ops_after_prepare_lock_failpoint.js b/jstests/replsets/ddl_ops_after_prepare_lock_failpoint.js
index d6633f85f16..a0d19c93b57 100644
--- a/jstests/replsets/ddl_ops_after_prepare_lock_failpoint.js
+++ b/jstests/replsets/ddl_ops_after_prepare_lock_failpoint.js
@@ -129,6 +129,6 @@
assert.commandWorked(
primary.adminCommand({configureFailPoint: "failNonIntentLocksIfWaitNeeded", mode: "off"}));
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
rst.stopSet();
})();
diff --git a/jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp_no_oplog_application.js b/jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp_no_oplog_application.js
index b00924048e5..898d1303383 100644
--- a/jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp_no_oplog_application.js
+++ b/jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp_no_oplog_application.js
@@ -111,7 +111,7 @@
jsTestLog("Aborting the second transaction");
- session2.abortTransaction_forTesting();
+ assert.commandWorked(session2.abortTransaction_forTesting());
replTest.stopSet();
})();
diff --git a/jstests/replsets/inmemory_preserves_active_txns.js b/jstests/replsets/inmemory_preserves_active_txns.js
index c5c6231c43e..2a5791b35ae 100644
--- a/jstests/replsets/inmemory_preserves_active_txns.js
+++ b/jstests/replsets/inmemory_preserves_active_txns.js
@@ -101,7 +101,7 @@
PrepareHelpers.commitTransaction(session, prepareTimestamp);
} else if (commitOrAbort === "abort") {
jsTestLog("Abort prepared transaction and wait for oplog to shrink to max oplogSize");
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
} else {
throw new Error(`Unrecognized value for commitOrAbort: ${commitOrAbort}`);
}
diff --git a/jstests/replsets/prepare_conflict_read_concern_behavior.js b/jstests/replsets/prepare_conflict_read_concern_behavior.js
index fce92d3c91c..a4858ae2053 100644
--- a/jstests/replsets/prepare_conflict_read_concern_behavior.js
+++ b/jstests/replsets/prepare_conflict_read_concern_behavior.js
@@ -252,38 +252,42 @@
"prepareTimestamp blocks on a prepared transaction.");
assert.commandFailedWithCode(read({}, failureTimeout, sessionDB2, collName),
ErrorCodes.MaxTimeMSExpired);
- session2.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session2.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
jsTestLog("Test read with read concern 'snapshot' and atClusterTime before " +
"prepareTimestamp doesn't block on a prepared transaction.");
session2.startTransaction(
{readConcern: {level: "snapshot", atClusterTime: clusterTimeBeforePrepare}});
assert.commandWorked(read({}, successTimeout, sessionDB2, collName, 2));
- session2.abortTransaction_forTesting();
+ assert.commandWorked(session2.abortTransaction_forTesting());
jsTestLog("Test read from a transaction with read concern 'majority' blocks on a prepared" +
" transaction.");
session2.startTransaction({readConcern: {level: "majority"}});
assert.commandFailedWithCode(read({}, failureTimeout, sessionDB2, collName),
ErrorCodes.MaxTimeMSExpired);
- session2.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session2.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
jsTestLog("Test read from a transaction with read concern 'local' blocks on a prepared " +
"transaction.");
session2.startTransaction({readConcern: {level: "local"}});
assert.commandFailedWithCode(read({}, failureTimeout, sessionDB2, collName),
ErrorCodes.MaxTimeMSExpired);
- session2.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session2.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
jsTestLog("Test read from a transaction with no read concern specified blocks on a " +
"prepared transaction.");
session2.startTransaction();
assert.commandFailedWithCode(read({}, failureTimeout, sessionDB2, collName),
ErrorCodes.MaxTimeMSExpired);
- session2.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session2.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
session2.endSession();
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
session.endSession();
}
diff --git a/jstests/replsets/recover_committed_aborted_prepared_transactions.js b/jstests/replsets/recover_committed_aborted_prepared_transactions.js
index 9b0d83fc0e7..031682b2064 100644
--- a/jstests/replsets/recover_committed_aborted_prepared_transactions.js
+++ b/jstests/replsets/recover_committed_aborted_prepared_transactions.js
@@ -62,7 +62,7 @@
assert.commandWorked(PrepareHelpers.commitTransaction(session1, prepareTimestamp));
// Abort the second transaction.
- session2.abortTransaction_forTesting();
+ assert.commandWorked(session2.abortTransaction_forTesting());
// Check that we have two transactions in the transactions table.
assert.eq(primary.getDB('config')['transactions'].find().itcount(), 2);
@@ -119,7 +119,7 @@
session1.startTransaction();
assert.commandWorked(sessionColl1.insert({_id: 6}));
PrepareHelpers.prepareTransaction(session1);
- session1.abortTransaction_forTesting();
+ assert.commandWorked(session1.abortTransaction_forTesting());
// Retrying the abortTransaction command should fail with a NoSuchTransaction error.
assert.commandFailedWithCode(sessionDB1.adminCommand({
abortTransaction: 1,
diff --git a/jstests/replsets/recover_prepared_transaction_state.js b/jstests/replsets/recover_prepared_transaction_state.js
index 6dd0032b1d9..f87d35496c8 100644
--- a/jstests/replsets/recover_prepared_transaction_state.js
+++ b/jstests/replsets/recover_prepared_transaction_state.js
@@ -83,7 +83,7 @@
// The following commit and abort will be rolled back.
rollbackTest.transitionToRollbackOperations();
PrepareHelpers.commitTransaction(session1, prepareTimestamp);
- session2.abortTransaction_forTesting();
+ assert.commandWorked(session2.abortTransaction_forTesting());
// The fastcount should be accurate because there are no open transactions.
assert.eq(testColl.count(), 3);
diff --git a/jstests/replsets/recovery_preserves_active_txns.js b/jstests/replsets/recovery_preserves_active_txns.js
index a848c96ae0e..5896a1e01fc 100644
--- a/jstests/replsets/recovery_preserves_active_txns.js
+++ b/jstests/replsets/recovery_preserves_active_txns.js
@@ -78,7 +78,7 @@
PrepareHelpers.commitTransaction(session, prepareTimestamp);
} else if (commitOrAbort === "abort") {
jsTestLog("Abort prepared transaction and wait for oplog to shrink to max oplogSize");
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
} else {
throw new Error(`Unrecognized value for commitOrAbort: ${commitOrAbort}`);
}
diff --git a/jstests/replsets/rollback_aborted_prepared_transaction.js b/jstests/replsets/rollback_aborted_prepared_transaction.js
index 8c47034901a..8a486323421 100644
--- a/jstests/replsets/rollback_aborted_prepared_transaction.js
+++ b/jstests/replsets/rollback_aborted_prepared_transaction.js
@@ -50,7 +50,7 @@
assert.eq(testColl.count(), 2);
// Abort the transaction explicitly.
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
assert.eq(testColl.find().itcount(), 1);
assert.eq(testColl.count(), 1);
diff --git a/jstests/replsets/rollover_preserves_active_txns.js b/jstests/replsets/rollover_preserves_active_txns.js
index 0e3eea0ca19..326cd764746 100644
--- a/jstests/replsets/rollover_preserves_active_txns.js
+++ b/jstests/replsets/rollover_preserves_active_txns.js
@@ -84,7 +84,7 @@
PrepareHelpers.commitTransaction(session, prepareTimestamp);
} else if (commitOrAbort === "abort") {
jsTestLog("Abort prepared transaction and wait for oplog to shrink to max oplogSize");
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
} else {
throw new Error(`Unrecognized value for commitOrAbort: ${commitOrAbort}`);
}
diff --git a/jstests/replsets/transactions_only_allowed_on_primaries.js b/jstests/replsets/transactions_only_allowed_on_primaries.js
index ea4ced8a05b..aaedea339aa 100644
--- a/jstests/replsets/transactions_only_allowed_on_primaries.js
+++ b/jstests/replsets/transactions_only_allowed_on_primaries.js
@@ -61,7 +61,8 @@
// Call abort for good measure, even though the transaction should have already been
// aborted on the server.
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NotMaster);
}
}
diff --git a/jstests/replsets/transient_txn_error_labels.js b/jstests/replsets/transient_txn_error_labels.js
index 06385622e60..defea4c774b 100644
--- a/jstests/replsets/transient_txn_error_labels.js
+++ b/jstests/replsets/transient_txn_error_labels.js
@@ -72,7 +72,8 @@
assert(res instanceof WriteCommandError);
assert(!res.hasOwnProperty("errorLabels"));
assert.commandWorked(testDB.adminCommand({configureFailPoint: "failCommand", mode: "off"}));
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
jsTest.log("WriteConflict returned by commitTransaction command is TransientTransactionError");
session.startTransaction();
@@ -125,7 +126,8 @@
assert(res instanceof WriteCommandError);
assert.eq(res.errorLabels, ["TransientTransactionError"]);
assert.commandWorked(testDB.adminCommand({configureFailPoint: "failCommand", mode: "off"}));
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
jsTest.log(
"ShutdownInProgress returned by commitTransaction command is not TransientTransactionError");
@@ -195,8 +197,9 @@
assert.commandFailedWithCode(res, ErrorCodes.LockTimeout);
assert(res instanceof WriteCommandError);
assert.eq(res.errorLabels, ["TransientTransactionError"]);
- sessionOther.abortTransaction_forTesting();
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(sessionOther.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
+ assert.commandWorked(session.abortTransaction_forTesting());
thread.join();
assert.commandWorked(thread.returnData());
@@ -213,7 +216,8 @@
res = sessionDb.runCommand({aggregate: collName, pipeline: [{$match: {}}], cursor: {}});
assert.commandFailedWithCode(res, ErrorCodes.HostUnreachable);
assert.eq(res.errorLabels, ["TransientTransactionError"]);
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
assert.commandWorked(testDB.adminCommand({configureFailPoint: "failCommand", mode: "off"}));
jsTest.log("Network errors for commit should not be transient");
@@ -231,7 +235,7 @@
});
assert.commandFailedWithCode(res, ErrorCodes.HostUnreachable);
assert(!res.hasOwnProperty("errorLabels"), tojson(res));
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
assert.commandWorked(testDB.adminCommand({configureFailPoint: "failCommand", mode: "off"}));
session.endSession();
diff --git a/jstests/sharding/libs/update_shard_key_helpers.js b/jstests/sharding/libs/update_shard_key_helpers.js
index f7c52067200..2260372bc6f 100644
--- a/jstests/sharding/libs/update_shard_key_helpers.js
+++ b/jstests/sharding/libs/update_shard_key_helpers.js
@@ -164,7 +164,8 @@ function runUpdateCmdFail(st,
if (errorCode) {
assert.commandFailedWithCode(res, errorCode);
}
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
} else {
res = sessionDB.foo.update(query, update, {multi: multiParamSet});
assert.writeError(res);
@@ -189,7 +190,8 @@ function runFindAndModifyCmdFail(
assert.throws(function() {
sessionDB.foo.findAndModify({query: query, update: update, "upsert": upsert});
});
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
} else {
assert.throws(function() {
sessionDB.foo.findAndModify({query: query, update: update, "upsert": upsert});
@@ -705,7 +707,8 @@ function assertCannotUpdateInBulkOpWhenDocsMoveShards(
bulkOp.execute();
});
if (inTxn) {
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
}
if (!ordered && !inTxn) {
@@ -755,7 +758,8 @@ function assertCannotUpdateInBulkOpWhenDocsMoveShards(
bulkOp.execute();
});
if (inTxn) {
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
}
if (!inTxn) {
@@ -799,7 +803,8 @@ function assertCannotUpdateInBulkOpWhenDocsMoveShards(
bulkOp.execute();
});
if (inTxn) {
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
}
// The batch will fail on the first write and the second will not be attempted.
@@ -833,7 +838,8 @@ function assertCannotUpdateInBulkOpWhenDocsMoveShards(
bulkOp.execute();
});
if (inTxn) {
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
}
assert.eq(1, st.s.getDB(kDbName).foo.find({"x": 300}).itcount());
@@ -981,4 +987,4 @@ function assertCanUpdatePrimitiveShardKeyHashedSameShards(
assertHashedShardKeyUpdateCorrect(st, kDbName, queries[1], updates[1], upsert, false);
st.s.getDB(kDbName).foo.drop();
-} \ No newline at end of file
+}
diff --git a/jstests/sharding/transactions_targeting_errors.js b/jstests/sharding/transactions_targeting_errors.js
index 2102977792e..9f490994c88 100644
--- a/jstests/sharding/transactions_targeting_errors.js
+++ b/jstests/sharding/transactions_targeting_errors.js
@@ -24,7 +24,8 @@
assert.commandFailedWithCode(res, ErrorCodes.InvalidOptions);
assert(res.hasOwnProperty("writeErrors"), "expected write errors, res: " + tojson(res));
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
// Failed delete.
@@ -34,7 +35,8 @@
assert.commandFailedWithCode(res, ErrorCodes.ShardKeyNotFound);
assert(res.hasOwnProperty("writeErrors"), "expected write errors, res: " + tojson(res));
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
st.stop();
}());
diff --git a/jstests/sharding/txn_agg.js b/jstests/sharding/txn_agg.js
index a606e817beb..9768ef41421 100644
--- a/jstests/sharding/txn_agg.js
+++ b/jstests/sharding/txn_agg.js
@@ -39,7 +39,7 @@
let res = sessionUnsharded.aggregate([{$match: {_id: {$gte: -200}}}]).toArray();
assert.eq(2, res.length, tojson(res));
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
// merge on mongos
@@ -52,7 +52,7 @@
res = sessionColl.aggregate([{$match: {_id: {$gte: -200}}}], {allowDiskUse: false}).toArray();
assert.eq(2, res.length, tojson(res));
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
// merge on shard. This will require the merging shard to open a cursor on itself.
session.startTransaction();
@@ -68,7 +68,7 @@
.toArray();
assert.eq(2, res.length, tojson(res));
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
// Error case: provide a readConcern on an operation which comes in the middle of a transaction.
session.startTransaction();
diff --git a/jstests/sharding/update_shard_key_doc_moves_shards.js b/jstests/sharding/update_shard_key_doc_moves_shards.js
index 1f68fd5626c..ff673d91390 100644
--- a/jstests/sharding/update_shard_key_doc_moves_shards.js
+++ b/jstests/sharding/update_shard_key_doc_moves_shards.js
@@ -91,7 +91,7 @@
} else {
assert.commandWorked(sessionDB.foo.update({"x": 300}, {"$set": {"x": 30}}));
}
- session.abortTransaction_forTesting();
+ assert.commandWorked(session.abortTransaction_forTesting());
assert.eq(1, mongos.getDB(kDbName).foo.find({"x": 300}).itcount());
assert.eq(0, mongos.getDB(kDbName).foo.find({"x": 30}).itcount());
}
@@ -290,7 +290,8 @@
assert.commandFailedWithCode(res, ErrorCodes.DuplicateKey);
assert(res.errmsg.includes(
"There is either an orphan for this document or _id for this collection is not globally unique."));
- session.abortTransaction_forTesting();
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
mongos.getDB(kDbName).foo.drop();
@@ -457,4 +458,4 @@
st.stop();
-})(); \ No newline at end of file
+})();