forked from canonical/pebble
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(servstate): don't hold both servicesLock and state lock at once (c…
…anonical#359) * fix(servstate): don't hold both servicesLock and state lock at once This avoids the 3-lock deadlock described in canonical#314. Other goroutines may be holding the state lock and waiting for the services lock, so it's problematic to acquire both locks at once. Break that part of the cycle. We could do this inside serviceForStart/serviceForStop by manually calling Unlock() sooner, but that's error-prone, so continue using defer, but have the caller write the task log (which needs the state lock) after the services lock is released. * Add regression test for the deadlock issue This test consistently FAILs without the fix in this PR, but consistently PASSes with the fix in this PR. The repro is basically as per the instructions at canonical#314 (comment)
- Loading branch information
Showing
2 changed files
with
136 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters