summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Jin Kang Park <yujin.kang@mongodb.com>2022-12-02 10:04:24 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-12-02 14:46:29 +0000
commitcb651c8d8e249fc96f8f0134f7c2a986bda2aba5 (patch)
tree3823a25dc6cb4dc36374e3bc650326412207bf77
parent7e8d18a464cd969b6d6c313dad790fdb9e27edea (diff)
downloadmongo-cb651c8d8e249fc96f8f0134f7c2a986bda2aba5.tar.gz
SERVER-71750 Revert writeConflictRetry refactor into handleWriteConflictException
(cherry picked from commit 552afb106b2cdc485db67087ce24e7d33e8cbabb)
-rw-r--r--src/mongo/db/concurrency/exception_util.cpp17
-rw-r--r--src/mongo/db/concurrency/exception_util.h10
2 files changed, 10 insertions, 17 deletions
diff --git a/src/mongo/db/concurrency/exception_util.cpp b/src/mongo/db/concurrency/exception_util.cpp
index 278c51cde80..37c447d3cd2 100644
--- a/src/mongo/db/concurrency/exception_util.cpp
+++ b/src/mongo/db/concurrency/exception_util.cpp
@@ -53,16 +53,6 @@ void logWriteConflictAndBackoff(int attempt, StringData operation, StringData ns
logAttrs(NamespaceString(ns)));
}
-void handleWriteConflictException(OperationContext* opCtx,
- int* writeConflictAttempts,
- StringData opStr,
- StringData ns) {
- CurOp::get(opCtx)->debug().additiveMetrics.incrementWriteConflicts(1);
- logWriteConflictAndBackoff(*writeConflictAttempts, opStr, ns);
- ++writeConflictAttempts;
- opCtx->recoveryUnit()->abandonSnapshot();
-}
-
namespace {
CounterMetric temporarilyUnavailableErrors{"operation.temporarilyUnavailableErrors"};
@@ -140,7 +130,12 @@ void handleTransactionTooLargeForCacheException(OperationContext* opCtx,
// only difference being the rate of retry. We prefer retrying faster, by converting to
// WriteConflictException, to avoid stalling replication longer than necessary.
transactionTooLargeForCacheErrorsConvertedToWriteConflict.increment(1);
- handleWriteConflictException(opCtx, writeConflictAttempts, opStr, ns);
+
+ // Handle as write conflict.
+ CurOp::get(opCtx)->debug().additiveMetrics.incrementWriteConflicts(1);
+ logWriteConflictAndBackoff(*writeConflictAttempts, opStr, ns);
+ ++(*writeConflictAttempts);
+ opCtx->recoveryUnit()->abandonSnapshot();
}
} // namespace mongo
diff --git a/src/mongo/db/concurrency/exception_util.h b/src/mongo/db/concurrency/exception_util.h
index 6e634cc3ac6..f88e3b7de7a 100644
--- a/src/mongo/db/concurrency/exception_util.h
+++ b/src/mongo/db/concurrency/exception_util.h
@@ -47,11 +47,6 @@ extern FailPoint skipWriteConflictRetries;
*/
void logWriteConflictAndBackoff(int attempt, StringData operation, StringData ns);
-void handleWriteConflictException(OperationContext* opCtx,
- int* writeConflictAttempts,
- StringData opStr,
- StringData ns);
-
void handleTemporarilyUnavailableException(OperationContext* opCtx,
int attempts,
StringData opStr,
@@ -146,7 +141,10 @@ auto writeConflictRetry(OperationContext* opCtx, StringData opStr, StringData ns
try {
return f();
} catch (WriteConflictException const&) {
- handleWriteConflictException(opCtx, &writeConflictAttempts, opStr, ns);
+ CurOp::get(opCtx)->debug().additiveMetrics.incrementWriteConflicts(1);
+ logWriteConflictAndBackoff(writeConflictAttempts, opStr, ns);
+ ++writeConflictAttempts;
+ opCtx->recoveryUnit()->abandonSnapshot();
} catch (TemporarilyUnavailableException const& e) {
handleTemporarilyUnavailableException(opCtx, ++attemptsTempUnavailable, opStr, ns, e);
} catch (TransactionTooLargeForCacheException const& e) {