summaryrefslogtreecommitdiff
path: root/src/mongo/db/session_catalog_mongod.cpp
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2019-04-18 17:26:44 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2019-05-02 17:32:13 -0400
commitdcf7912e275b72d1462d4ecf26f195f8accb45ad (patch)
treed96248496d8fa66ccd73fb3c1038bd67c801ad10 /src/mongo/db/session_catalog_mongod.cpp
parentdabbf059e6f96edb4898b42d532d460efd2510f2 (diff)
downloadmongo-dcf7912e275b72d1462d4ecf26f195f8accb45ad.tar.gz
SERVER-36483 Do not reap transaction entries for prepared transactions
Diffstat (limited to 'src/mongo/db/session_catalog_mongod.cpp')
-rw-r--r--src/mongo/db/session_catalog_mongod.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/mongo/db/session_catalog_mongod.cpp b/src/mongo/db/session_catalog_mongod.cpp
index d17280e9ca3..39880028b28 100644
--- a/src/mongo/db/session_catalog_mongod.cpp
+++ b/src/mongo/db/session_catalog_mongod.cpp
@@ -202,8 +202,17 @@ void MongoDSessionCatalog::invalidateSessions(OperationContext* opCtx,
auto sessionKillTokens = std::make_shared<std::vector<SessionCatalog::KillToken>>();
if (singleSessionDoc) {
- sessionKillTokens->emplace_back(catalog->killSession(LogicalSessionId::parse(
- IDLParserErrorContext("lsid"), singleSessionDoc->getField("_id").Obj())));
+ const auto lsid = LogicalSessionId::parse(IDLParserErrorContext("lsid"),
+ singleSessionDoc->getField("_id").Obj());
+ catalog->scanSession(lsid, [&sessionKillTokens](const ObservableSession& session) {
+ const auto participant = TransactionParticipant::get(session);
+ uassert(ErrorCodes::PreparedTransactionInProgress,
+ str::stream() << "Cannot modify the entry for session "
+ << session.getSessionId().getId()
+ << " because it is in the prepared state",
+ !participant.transactionIsPrepared());
+ sessionKillTokens->emplace_back(session.kill());
+ });
} else {
SessionKiller::Matcher matcher(
KillAllSessionsByPatternSet{makeKillAllSessionsByPattern(opCtx)});