summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseanzimm <sean.zimmerman@mongodb.com>2023-02-09 22:30:31 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-02-10 01:41:43 +0000
commitc835341f9706373fb46ba7a6fc37d9892c42a967 (patch)
treed1fd0ec93b46894bf6db78e496d8fe1e49f6dcf7
parent66d62e802b3e952b73daf61545fd31158f198189 (diff)
downloadmongo-c835341f9706373fb46ba7a6fc37d9892c42a967.tar.gz
SERVER-70642: Add ticket acquisition skip for node step up
-rw-r--r--src/mongo/db/session/session_catalog_mongod.cpp5
-rw-r--r--src/mongo/db/transaction/transaction_participant.cpp4
-rw-r--r--src/mongo/db/transaction/transaction_participant.h2
3 files changed, 7 insertions, 4 deletions
diff --git a/src/mongo/db/session/session_catalog_mongod.cpp b/src/mongo/db/session/session_catalog_mongod.cpp
index dc229888362..8cc38f21f33 100644
--- a/src/mongo/db/session/session_catalog_mongod.cpp
+++ b/src/mongo/db/session/session_catalog_mongod.cpp
@@ -35,6 +35,7 @@
#include "mongo/bson/bsonmisc.h"
#include "mongo/db/catalog_raii.h"
#include "mongo/db/client.h"
+#include "mongo/db/concurrency/lock_state.h"
#include "mongo/db/create_indexes_gen.h"
#include "mongo/db/dbdirectclient.h"
#include "mongo/db/index_builds_coordinator.h"
@@ -512,6 +513,10 @@ void MongoDSessionCatalog::onStepUp(OperationContext* opCtx) {
for (const auto& sessionInfo : sessionsToReacquireLocks) {
auto newOpCtx = cc().makeOperationContext();
+ // Avoid ticket acquisition during step up.
+ SetAdmissionPriorityForLock setTicketAquisition(newOpCtx.get(),
+ AdmissionContext::Priority::kImmediate);
+
// Synchronize with killOps to make this unkillable.
{
auto lk = stdx::lock_guard(*newOpCtx->getClient());
diff --git a/src/mongo/db/transaction/transaction_participant.cpp b/src/mongo/db/transaction/transaction_participant.cpp
index ca711476df9..72df0adddd4 100644
--- a/src/mongo/db/transaction/transaction_participant.cpp
+++ b/src/mongo/db/transaction/transaction_participant.cpp
@@ -1598,9 +1598,7 @@ void TransactionParticipant::Participant::refreshLocksForPreparedTransaction(
invariant(o().txnResourceStash);
invariant(o().txnState.isPrepared());
- // Lock and Ticket reacquisition of a prepared transaction should not fail for
- // state transitions (step up/step down).
- _releaseTransactionResourcesToOpCtx(opCtx, MaxLockTimeout::kNotAllowed, AcquireTicket::kNoSkip);
+ _releaseTransactionResourcesToOpCtx(opCtx, MaxLockTimeout::kNotAllowed, AcquireTicket::kSkip);
// Snapshot transactions don't conflict with PBWM lock on both primary and secondary.
invariant(!opCtx->lockState()->shouldConflictWithSecondaryBatchApplication());
diff --git a/src/mongo/db/transaction/transaction_participant.h b/src/mongo/db/transaction/transaction_participant.h
index 152637db865..c550e737281 100644
--- a/src/mongo/db/transaction/transaction_participant.h
+++ b/src/mongo/db/transaction/transaction_participant.h
@@ -1008,7 +1008,7 @@ public:
* | | Commit/ | Other Txn | | |
* | | Abort Cmd | Cmds | | |
* | |-----------------------| | |
- * |acquireTicket | kSkip | kNoSkip | kNoSkip | kNoSkip |
+ * |acquireTicket | kSkip | kNoSkip | kNoSkip | kSkip |
* |----------------|-----------------------|---------------|------------------|
* |maxLockTimeout | kAllowed | kNotAllowed | kNotAllowed |
* -----------------------------------------------------------------------------