diff options
author | Jack Mulrow <jack.mulrow@mongodb.com> | 2023-05-03 19:38:14 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-05-03 21:13:53 +0000 |
commit | 693d1b831df752bc37e866733229f6dcf88c6944 (patch) | |
tree | 10adbe591c6388e0a0dc4ec7eed8b0a48995fb78 | |
parent | 2551dcba41eb480d32110181956fc25fa3d102f2 (diff) | |
download | mongo-693d1b831df752bc37e866733229f6dcf88c6944.tar.gz |
SERVER-75821 Only end session in onPrimaryTransactionalWrite if client has one
-rw-r--r-- | jstests/sharding/retryable_writes.js | 6 | ||||
-rw-r--r-- | src/mongo/db/transaction/transaction_participant.cpp | 4 |
2 files changed, 3 insertions, 7 deletions
diff --git a/jstests/sharding/retryable_writes.js b/jstests/sharding/retryable_writes.js index c673aa27354..2f8d78e7bc3 100644 --- a/jstests/sharding/retryable_writes.js +++ b/jstests/sharding/retryable_writes.js @@ -329,12 +329,6 @@ function runFailpointTests(mainConn, priConn) { var lsid = UUID(); var testDb = mainConn.getDB('TestDB'); - if (TestData.configShard) { - // TODO SERVER-75821: Workaround for crash when executing the fail point while implicitly - // creating a collection in a transaction on the config server. - assert.commandWorked(testDb.createCollection("user")); - } - // Test connection close (default behaviour). The connection will get closed, but the // inserts must succeed assert.commandWorked(priConn.adminCommand( diff --git a/src/mongo/db/transaction/transaction_participant.cpp b/src/mongo/db/transaction/transaction_participant.cpp index beb399820e8..39894d4a12e 100644 --- a/src/mongo/db/transaction/transaction_participant.cpp +++ b/src/mongo/db/transaction/transaction_participant.cpp @@ -3530,7 +3530,9 @@ void TransactionParticipant::Participant::_registerUpdateCacheOnCommit( onPrimaryTransactionalWrite.execute([&](const BSONObj& data) { const auto closeConnectionElem = data["closeConnection"]; if (closeConnectionElem.eoo() || closeConnectionElem.Bool()) { - opCtx->getClient()->session()->end(); + if (auto session = opCtx->getClient()->session()) { + session->end(); + } } const auto failBeforeCommitExceptionElem = data["failBeforeCommitExceptionCode"]; |