diff options
author | Suganthi Mani <suganthi.mani@mongodb.com> | 2019-07-25 00:02:55 -0400 |
---|---|---|
committer | Suganthi Mani <suganthi.mani@mongodb.com> | 2019-07-25 00:02:55 -0400 |
commit | be06cfaae8872737fe349a8a400f322123307061 (patch) | |
tree | 2b73caf3d01c62a708ae06ad9a6b523fcfb7c2e9 /src/mongo/db/concurrency | |
parent | 2ff54098b19ebc2b4bbf5516de6e6befb46f9fe7 (diff) | |
download | mongo-be06cfaae8872737fe349a8a400f322123307061.tar.gz |
SERVER-41980 Prepared transactions should not acquire ticket on primary.
Diffstat (limited to 'src/mongo/db/concurrency')
-rw-r--r-- | src/mongo/db/concurrency/d_concurrency_test.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/concurrency/locker.h | 12 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/mongo/db/concurrency/d_concurrency_test.cpp b/src/mongo/db/concurrency/d_concurrency_test.cpp index cb310b55eb9..1a0b49a9e82 100644 --- a/src/mongo/db/concurrency/d_concurrency_test.cpp +++ b/src/mongo/db/concurrency/d_concurrency_test.cpp @@ -1476,7 +1476,7 @@ TEST_F(DConcurrencyTestFixture, NoThrottlingWhenNotAcquiringTickets) { UseGlobalThrottling throttle(opctx1, 1); // Prevent the enforcement of ticket throttling. - opctx1->lockState()->setShouldAcquireTicket(false); + opctx1->lockState()->skipAcquireTicket(); // Both locks should be acquired immediately because there is no throttling. Lock::GlobalRead R1(opctx1, Date_t::now(), Lock::InterruptBehavior::kThrow); diff --git a/src/mongo/db/concurrency/locker.h b/src/mongo/db/concurrency/locker.h index 47996f9b62a..746b65fa40d 100644 --- a/src/mongo/db/concurrency/locker.h +++ b/src/mongo/db/concurrency/locker.h @@ -499,13 +499,15 @@ public: } /** - * If set to false, this opts out of the ticket mechanism. This should be used sparingly - * for special purpose threads, such as FTDC. + * This will opt out of the ticket mechanism. This should be used sparingly for special purpose + * threads, such as FTDC and committing or aborting prepared transactions. */ - void setShouldAcquireTicket(bool newValue) { - invariant(!isLocked() || isNoop()); - _shouldAcquireTicket = newValue; + void skipAcquireTicket() { + // Should not hold or wait for the ticket. + invariant(isNoop() || getClientState() == Locker::ClientState::kInactive); + _shouldAcquireTicket = false; } + bool shouldAcquireTicket() const { return _shouldAcquireTicket; } |