nsenter: use TryLock in reaper to prevent cascading FUSE deadlock#119
Open
okhowang wants to merge 1 commit intonestybox:masterfrom
Open
nsenter: use TryLock in reaper to prevent cascading FUSE deadlock#119okhowang wants to merge 1 commit intonestybox:masterfrom
okhowang wants to merge 1 commit intonestybox:masterfrom
Conversation
Replace mu.Lock() with mu.TryLock() in the zombie reaper goroutine. Go's sync.RWMutex implements writer-preference: a pending Lock() blocks all subsequent RLock() callers. When the reaper's Lock() is pending while an nsenter child holds RLock, all new FUSE Lookup handlers are blocked from acquiring RLock to start their own nsenter processes. If the nsenter child's operation triggers a FUSE request back to sysbox-fs, the FUSE handler cannot proceed, creating a deadlock. TryLock() does not register a pending writer, so FUSE handlers can still acquire RLock. If TryLock fails, the reaper sleep a second to retry. Fixes: nestybox/sysbox#1002 Signed-off-by: okhowang(王沛文) <okhowang@tencent.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace mu.Lock() with mu.TryLock() in the zombie reaper goroutine. Go's sync.RWMutex implements writer-preference: a pending Lock() blocks all subsequent RLock() callers. When the reaper's Lock() is pending while an nsenter child holds RLock, all new FUSE Lookup handlers are blocked from acquiring RLock to start their own nsenter processes. If the nsenter child's operation triggers a FUSE request back to sysbox-fs, the FUSE handler cannot proceed, creating a deadlock.
TryLock() does not register a pending writer, so FUSE handlers can still acquire RLock. If TryLock fails, the reaper sleep a second to retry.
Fixes: nestybox/sysbox#1002