summaryrefslogtreecommitdiff
path: root/src/mongo/db/concurrency/lock_state_test.cpp
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2019-04-02 13:48:20 -0400
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2019-04-02 13:48:20 -0400
commit4438eacf2c396e4bc1971f1d4609d81269f24016 (patch)
tree3ff9c973345a08bc2ddf07c0a6ae8647c333059d /src/mongo/db/concurrency/lock_state_test.cpp
parent4b5ea6e22404c5ebb5208bd96fad69ba2fa0cdb8 (diff)
downloadmongo-4438eacf2c396e4bc1971f1d4609d81269f24016.tar.gz
SERVER-40420 Clean up failed lock requests when using failpoint.
Using the "failNonIntentLocksIfWaitNeeded" failpoint with ResourceLock would otherwise lead to invariant failure when destructing the Locker.
Diffstat (limited to 'src/mongo/db/concurrency/lock_state_test.cpp')
-rw-r--r--src/mongo/db/concurrency/lock_state_test.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mongo/db/concurrency/lock_state_test.cpp b/src/mongo/db/concurrency/lock_state_test.cpp
index 9cde8585229..63eb6e1a676 100644
--- a/src/mongo/db/concurrency/lock_state_test.cpp
+++ b/src/mongo/db/concurrency/lock_state_test.cpp
@@ -156,6 +156,10 @@ TEST(LockerImpl, FailPointInLockFailsNonIntentLocksIfTheyCannotBeImmediatelyGran
locker2.lockGlobal(MODE_IS);
ASSERT_THROWS_CODE(
locker2.lock(resId, MODE_S, Date_t::max()), DBException, ErrorCodes::LockTimeout);
+
+ // The timed out MODE_S attempt shouldn't be present in the map of lock requests because it
+ // won't ever be granted.
+ ASSERT(locker2.getRequestsForTest().find(resId).finished());
locker2.unlockGlobal();
// MODE_X attempt.
@@ -163,6 +167,10 @@ TEST(LockerImpl, FailPointInLockFailsNonIntentLocksIfTheyCannotBeImmediatelyGran
locker3.lockGlobal(MODE_IX);
ASSERT_THROWS_CODE(
locker3.lock(resId, MODE_X, Date_t::max()), DBException, ErrorCodes::LockTimeout);
+
+ // The timed out MODE_X attempt shouldn't be present in the map of lock requests because it
+ // won't ever be granted.
+ ASSERT(locker3.getRequestsForTest().find(resId).finished());
locker3.unlockGlobal();
}