summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Witten <andrew.witten@mongodb.com>2022-04-25 20:41:20 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-05-06 14:15:29 +0000
commit4a919ea37a9bccd2941f9eb0c7ac7a72ae178833 (patch)
tree61f9ecc7cc470628650b0b1d9200fcc1cce3557d
parent5d80a6fad7b11d69f51e73353cf6712f05c5d1d2 (diff)
downloadmongo-r5.0.9-rc0.tar.gz
SERVER-65633 retry commitTransaction on FailedToSatisfyReadPreferencer5.0.9-rc0
(cherry picked from commit e90e25cc5ad352d0c8b074f0ad49945b483d7131)
-rw-r--r--jstests/concurrency/fsm_workload_helpers/auto_retry_transaction.js19
1 files changed, 14 insertions, 5 deletions
diff --git a/jstests/concurrency/fsm_workload_helpers/auto_retry_transaction.js b/jstests/concurrency/fsm_workload_helpers/auto_retry_transaction.js
index 9097740d723..174e68f4d3b 100644
--- a/jstests/concurrency/fsm_workload_helpers/auto_retry_transaction.js
+++ b/jstests/concurrency/fsm_workload_helpers/auto_retry_transaction.js
@@ -35,7 +35,7 @@ var {withTxnAndAutoRetry, isKilledSessionCode} = (function() {
// Don't retry the entire transaction on commit errors that aren't labeled as transient
// transaction errors because it's unknown if the commit succeeded. commitTransaction is
// individually retryable and should be retried at a lower level (e.g.
- // network_error_and_txn_override.js or commitTransactionWithKilledSessionRetries()), so any
+ // network_error_and_txn_override.js or commitTransactionWithRetries()), so any
// error that reached here must not be transient.
if (hasCommitTxnError) {
print("-=-=-=- Cannot retry entire transaction on commit transaction error without" +
@@ -60,8 +60,9 @@ var {withTxnAndAutoRetry, isKilledSessionCode} = (function() {
}
// Commits the transaction active on the given session, retrying on killed session errors if
- // configured to do so. Throws if the commit fails and cannot be retried.
- function commitTransactionWithKilledSessionRetries(session, retryOnKilledSession) {
+ // configured to do so. Also retries commitTransaction on FailedToSatisfyReadPreference error.
+ // Throws if the commit fails and cannot be retried.
+ function commitTransactionWithRetries(session, retryOnKilledSession) {
while (true) {
const commitRes = session.commitTransaction_forTesting();
@@ -76,6 +77,14 @@ var {withTxnAndAutoRetry, isKilledSessionCode} = (function() {
continue;
}
+ if (commitRes.code === ErrorCodes.FailedToSatisfyReadPreference) {
+ print("-=-=-=- Retrying commit due to FailedToSatisfyReadPreference, sessionId: " +
+ tojsononeline(session.getSessionId()) +
+ ", txnNumber: " + tojsononeline(session.getTxnNumber_forTesting()) +
+ ", res: " + tojsononeline(commitRes));
+ continue;
+ }
+
// Use assert.commandWorked() because it throws an exception in the format expected by
// the caller of this function if the commit failed. Committing may fail with a
// transient error that can be retried on at a higher level, so suppress unnecessary
@@ -139,7 +148,7 @@ var {withTxnAndAutoRetry, isKilledSessionCode} = (function() {
const prepareTimestamp = PrepareHelpers.prepareTransaction(session);
PrepareHelpers.commitTransaction(session, prepareTimestamp);
} else {
- commitTransactionWithKilledSessionRetries(session, retryOnKilledSession);
+ commitTransactionWithRetries(session, retryOnKilledSession);
}
} catch (e) {
hasCommitTxnError = true;
@@ -160,7 +169,7 @@ var {withTxnAndAutoRetry, isKilledSessionCode} = (function() {
}
if (shouldRetryEntireTxnOnError(e, hasCommitTxnError, retryOnKilledSession)) {
- print("Retrying transaction due to transient error.");
+ print("Retrying transaction due to transient error: " + tojson(e));
hasTransientError = true;
continue;
}