summaryrefslogtreecommitdiff
path: root/src
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>2023-02-06 11:17:18 +0000
commit415264d37f9f262a240a5422e61b328cac28d165 (patch)
tree801e7ae9d771f93f9555fa2bc6406ede2bbb408a /src
parent05c9f930eaaae18b8abb7058aacc93fe0549aadf (diff)
downloadmongo-415264d37f9f262a240a5422e61b328cac28d165.tar.gz
SERVER-71750 Revert writeConflictRetry refactor into handleWriteConflictException
(cherry picked from commit 552afb106b2cdc485db67087ce24e7d33e8cbabb)
Diffstat (limited to 'src')
-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 f6505cfb90b..396c7b1b30e 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 {
Counter64 temporarilyUnavailableErrors;
@@ -150,7 +140,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 b656e9cb687..9aac97b9d70 100644
--- a/src/mongo/db/concurrency/exception_util.h
+++ b/src/mongo/db/concurrency/exception_util.h
@@ -49,11 +49,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,
@@ -125,7 +120,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) {