summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeert Bosch <geert@mongodb.com>2017-12-08 17:52:41 -0500
committerGeert Bosch <geert@mongodb.com>2018-01-03 12:54:20 -0500
commit707f2e26f01bc9fa126877a275486f80f58ab004 (patch)
tree9f1cd10a2e800092223ac886e32e4cd26e4c1956
parent1ba3872f61c84c1c1a1031d763c8f4d8a2c78be8 (diff)
downloadmongo-707f2e26f01bc9fa126877a275486f80f58ab004.tar.gz
SERVER-32242 Fix race in CompatibleFirstStress lock manager test
(cherry picked from commit cc13cb76a07a01cb0eb14bd4516a9ef9c073f1c7)
-rw-r--r--src/mongo/db/concurrency/d_concurrency_test.cpp3
-rw-r--r--src/mongo/db/concurrency/lock_state.cpp5
2 files changed, 4 insertions, 4 deletions
diff --git a/src/mongo/db/concurrency/d_concurrency_test.cpp b/src/mongo/db/concurrency/d_concurrency_test.cpp
index eb09f99b8d3..327f1efddc5 100644
--- a/src/mongo/db/concurrency/d_concurrency_test.cpp
+++ b/src/mongo/db/concurrency/d_concurrency_test.cpp
@@ -982,10 +982,7 @@ TEST(DConcurrency, CompatibleFirstStress) {
// MODE_IS or MODE_S lock, the CompatibleFirst policy guarantees success.
auto newInterval = readOnlyInterval.load();
invariant(!interval || interval != newInterval || lock->isLocked());
- interval = newInterval;
lock->waitForLock(0);
- newInterval = readOnlyInterval.load();
- invariant(!interval || interval != newInterval || lock->isLocked());
break;
}
case 5:
diff --git a/src/mongo/db/concurrency/lock_state.cpp b/src/mongo/db/concurrency/lock_state.cpp
index 45ea279c137..bf48ec3ba51 100644
--- a/src/mongo/db/concurrency/lock_state.cpp
+++ b/src/mongo/db/concurrency/lock_state.cpp
@@ -787,7 +787,10 @@ LockResult LockerImpl<IsForMMAPV1>::lockComplete(ResourceId resId,
}
}
- // Cleanup the state, since this is an unused lock now
+ // Cleanup the state, since this is an unused lock now.
+ // Note: in case of the _notify object returning LOCK_TIMEOUT, it is possible to find that the
+ // lock was still granted after all, but we don't try to take advantage of that and will return
+ // a timeout.
if (result != LOCK_OK) {
LockRequestsMap::Iterator it = _requests.find(resId);
_unlockImpl(&it);