summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorSuganthi Mani <suganthi.mani@mongodb.com>2019-07-24 23:47:28 -0400
committerSuganthi Mani <suganthi.mani@mongodb.com>2019-07-24 23:47:28 -0400
commitf5f62f877b62523205d02f810f351b06cf1e58c4 (patch)
tree72aecb3bfc7733fb66b0043319a54df531503a64 /src/mongo
parentc803a014930218b5a9ee81fee32598b3b6893c63 (diff)
downloadmongo-f5f62f877b62523205d02f810f351b06cf1e58c4.tar.gz
SERVER-42388 Release the transaction lock resources and abort storage
transaction for unprepared transactions on failure to unstash the transaction resources to opCtx.
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/service_entry_point_common.cpp10
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] {