diff options
author | Benety Goh <benety@mongodb.com> | 2020-02-10 16:53:38 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-19 11:17:06 +0000 |
commit | 7d6f64a440076a8ff644188eb4d069a5ec7d490b (patch) | |
tree | f43ad063ed2b3011d83e71ca50c37cbf2626332f /src/mongo/db/concurrency | |
parent | 6e81decdf230de5a6e9fc1dd9b2e5a54e78d6d7c (diff) | |
download | mongo-7d6f64a440076a8ff644188eb4d069a5ec7d490b.tar.gz |
SERVER-45007 PBWM lock acquisition in GlobalLock supports deadline
(cherry picked from commit 73acb91e3989754ffa0ea98dc908362cad76c1ef)
Diffstat (limited to 'src/mongo/db/concurrency')
-rw-r--r-- | src/mongo/db/concurrency/d_concurrency.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/concurrency/d_concurrency_test.cpp | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/mongo/db/concurrency/d_concurrency.cpp b/src/mongo/db/concurrency/d_concurrency.cpp index 5fe256c5c40..93f7ec0c711 100644 --- a/src/mongo/db/concurrency/d_concurrency.cpp +++ b/src/mongo/db/concurrency/d_concurrency.cpp @@ -172,7 +172,7 @@ void Lock::GlobalLock::_enqueue(LockMode lockMode, Date_t deadline) { try { if (_opCtx->lockState()->shouldConflictWithSecondaryBatchApplication()) { - _pbwm.lock(_opCtx, MODE_IS); + _pbwm.lock(_opCtx, MODE_IS, deadline); } auto unlockPBWM = makeGuard([this] { if (_opCtx->lockState()->shouldConflictWithSecondaryBatchApplication()) { diff --git a/src/mongo/db/concurrency/d_concurrency_test.cpp b/src/mongo/db/concurrency/d_concurrency_test.cpp index a8c6553fb03..fd0c3160301 100644 --- a/src/mongo/db/concurrency/d_concurrency_test.cpp +++ b/src/mongo/db/concurrency/d_concurrency_test.cpp @@ -468,6 +468,24 @@ TEST_F(DConcurrencyTestFixture, RSTLmodeX_Timeout) { MODE_NONE); } +TEST_F(DConcurrencyTestFixture, PBWMmodeX_Timeout) { + auto clients = makeKClientsWithLockers(2); + Lock::ParallelBatchWriterMode pbwm(clients[0].second.get()->lockState()); + ASSERT_EQ(clients[0].second.get()->lockState()->getLockMode(resourceIdParallelBatchWriterMode), + MODE_X); + + ASSERT_THROWS_CODE(Lock::GlobalLock(clients[1].second.get(), + MODE_X, + Date_t::now() + Milliseconds(1), + Lock::InterruptBehavior::kThrow), + AssertionException, + ErrorCodes::LockTimeout); + ASSERT_EQ(clients[0].second.get()->lockState()->getLockMode(resourceIdParallelBatchWriterMode), + MODE_X); + ASSERT_EQ(clients[1].second.get()->lockState()->getLockMode(resourceIdParallelBatchWriterMode), + MODE_NONE); +} + TEST_F(DConcurrencyTestFixture, GlobalLockXSetsGlobalWriteLockedOnOperationContext) { auto clients = makeKClientsWithLockers(1); auto opCtx = clients[0].second.get(); |