diff options
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/service_entry_point_common.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp index 3b8795c6d5a..59e88663ef2 100644 --- a/src/mongo/db/service_entry_point_common.cpp +++ b/src/mongo/db/service_entry_point_common.cpp @@ -406,7 +406,17 @@ void invokeWithSessionCheckedOut(OperationContext* opCtx, readConcernArgs.isEmpty()); } + // Release the transaction lock resources and abort storage transaction for unprepared + // transactions on failure to unstash the transaction resources to opCtx. We don't want to + // have this error guard for beginOrContinue as it can abort the transaction for any + // accidental invalid statements in the transaction. + auto abortOnError = makeGuard( + [&txnParticipant, opCtx] { txnParticipant.abortTransactionIfNotPrepared(opCtx); }); + txnParticipant.unstashTransactionResources(opCtx, invocation->definition()->getName()); + + // Unstash success. + abortOnError.dismiss(); } auto guard = makeGuard([&txnParticipant, opCtx] { |