[SERVER-40420] Using failNonIntentLocksIfWaitNeeded failpoint may leave behind failed lock requests Created: 01/Apr/19  Updated: 29/Oct/23  Resolved: 02/Apr/19

Status: Closed
Project: Core Server
Component/s: Concurrency, Testing Infrastructure
Affects Version/s: None
Fix Version/s: 4.1.10

Type: Bug Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Max Hirschhorn
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
is related to SERVER-39154 Create a fail point to make it so if... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: STM 2019-04-08
Participants:

 Description   

The failNonIntentLocksIfWaitNeeded failpoint assumes that LockerImpl::unlockGlobal() will eventually be called before the LockerImpl is destructed. This was found not to be the case with the RESOURCE_METADATA lock acquired for capped collections via a ResourceLock instance.

if (_needCappedLock) {
    // X-lock the metadata resource for this capped collection until the end of the WUOW. This
    // prevents the primary from executing with more concurrency than secondaries.
    // See SERVER-21646.
    Lock::ResourceLock heldUntilEndOfWUOW{
        opCtx->lockState(), ResourceId(RESOURCE_METADATA, _ns.ns()), MODE_X};
}

Instead, the MONGO_FAIL_POINT(failNonIntentLocksIfWaitNeeded) blocks should be guarded by the unlockOnErrorGuard to ensure LockerImpl::_unlockImpl() gets called after we uassert().

// Clean up the state on any failed lock attempts.
auto unlockOnErrorGuard = makeGuard([&] {
    LockRequestsMap::Iterator it = _requests.find(resId);
    _unlockImpl(&it);
});



 Comments   
Comment by Githook User [ 02/Apr/19 ]

Author:

{'email': 'max.hirschhorn@mongodb.com', 'name': 'Max Hirschhorn', 'username': 'visemet'}

Message: 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.
Branch: master
https://github.com/mongodb/mongo/commit/4438eacf2c396e4bc1971f1d4609d81269f24016

Generated at Thu Feb 08 04:54:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.