diff options
author | Misha Tyulenev <misha@mongodb.com> | 2019-03-20 17:01:32 -0400 |
---|---|---|
committer | Misha Tyulenev <misha@mongodb.com> | 2019-03-20 17:01:32 -0400 |
commit | 1144316212453346cb17ae0992542b192755ae04 (patch) | |
tree | 098f8412431dfa1bd2e48677a5ec31edb42a3c3b /src | |
parent | 2f9c6b9a80c8d86cdc68be3a421e44b45dfd03d0 (diff) | |
download | mongo-1144316212453346cb17ae0992542b192755ae04.tar.gz |
SERVER-39932 do not checkout session if retriable writes are not used
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/service_entry_point_mongod.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mongo/db/service_entry_point_mongod.cpp b/src/mongo/db/service_entry_point_mongod.cpp index ec8bc6e75ae..128c3ff3368 100644 --- a/src/mongo/db/service_entry_point_mongod.cpp +++ b/src/mongo/db/service_entry_point_mongod.cpp @@ -633,9 +633,11 @@ void execCommandDatabase(OperationContext* opCtx, // Session ids are forwarded in requests, so commands that require roundtrips between // servers may result in a deadlock when a server tries to check out a session it is already // using to service an earlier operation in the command's chain. To avoid this, only check - // out sessions for commands that require them (i.e. write commands). - OperationContextSession sessionTxnState( - opCtx, cmdWhitelist.find(command->getName()) != cmdWhitelist.cend()); + // out sessions with provided txnNumber for commands that require them (i.e. write + // commands). + bool checkoutSession = + opCtx->getTxnNumber() && (cmdWhitelist.find(command->getName()) != cmdWhitelist.cend()); + OperationContextSession sessionTxnState(opCtx, checkoutSession); ImpersonationSessionGuard guard(opCtx); uassertStatusOK(Command::checkAuthorization(command, opCtx, request)); |