diff options
author | Sophia Tan <sophia_tll@hotmail.com> | 2023-05-12 19:44:44 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-05-15 23:20:28 +0000 |
commit | 6be86d8987dbad1c33160ef1779b598bc7cfa6b4 (patch) | |
tree | b3484e6c70e402ddf66482df828c3b3f221457b3 /src/mongo/db/concurrency/exception_util.h | |
parent | ba0986ac66e3a22d211ad3707ad037fdc10910af (diff) | |
download | mongo-6be86d8987dbad1c33160ef1779b598bc7cfa6b4.tar.gz |
SERVER-75276 writeConflictRetry should properly be using a NamespaceStringOrUUID instead of a StringData
Diffstat (limited to 'src/mongo/db/concurrency/exception_util.h')
-rw-r--r-- | src/mongo/db/concurrency/exception_util.h | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/mongo/db/concurrency/exception_util.h b/src/mongo/db/concurrency/exception_util.h index dca5b4f109e..103015d2d25 100644 --- a/src/mongo/db/concurrency/exception_util.h +++ b/src/mongo/db/concurrency/exception_util.h @@ -126,7 +126,10 @@ template <ErrorCodes::Error ec> * invocation of the argument function f without any exception handling and retry logic. */ template <typename F> -auto writeConflictRetry(OperationContext* opCtx, StringData opStr, StringData ns, F&& f) { +auto writeConflictRetry(OperationContext* opCtx, + StringData opStr, + const NamespaceStringOrUUID& nssOrUUID, + F&& f) { invariant(opCtx); invariant(opCtx->lockState()); invariant(opCtx->recoveryUnit()); @@ -141,7 +144,9 @@ auto writeConflictRetry(OperationContext* opCtx, StringData opStr, StringData ns return f(); } catch (TemporarilyUnavailableException const& e) { if (opCtx->inMultiDocumentTransaction()) { - handleTemporarilyUnavailableExceptionInTransaction(opCtx, opStr, ns, e); + // TODO SERVER-76897: use nssOrUUID.toStringForLogging(). + handleTemporarilyUnavailableExceptionInTransaction( + opCtx, opStr, nssOrUUID.toStringForErrorMsg(), e); } throw; } @@ -154,13 +159,16 @@ auto writeConflictRetry(OperationContext* opCtx, StringData opStr, StringData ns return f(); } catch (WriteConflictException const& e) { CurOp::get(opCtx)->debug().additiveMetrics.incrementWriteConflicts(1); - logWriteConflictAndBackoff(writeConflictAttempts, opStr, e.reason(), ns); + logWriteConflictAndBackoff( + writeConflictAttempts, opStr, e.reason(), nssOrUUID.toStringForErrorMsg()); ++writeConflictAttempts; opCtx->recoveryUnit()->abandonSnapshot(); } catch (TemporarilyUnavailableException const& e) { - handleTemporarilyUnavailableException(opCtx, ++attemptsTempUnavailable, opStr, ns, e); + handleTemporarilyUnavailableException( + opCtx, ++attemptsTempUnavailable, opStr, nssOrUUID.toStringForErrorMsg(), e); } catch (TransactionTooLargeForCacheException const& e) { - handleTransactionTooLargeForCacheException(opCtx, &writeConflictAttempts, opStr, ns, e); + handleTransactionTooLargeForCacheException( + opCtx, &writeConflictAttempts, opStr, nssOrUUID.toStringForErrorMsg(), e); } } } |