Skip to content

Fix: Recursive Read Lock Deadlock in GetSFWContentMode - #7300

Open
hoanle0126 wants to merge 1 commit into
stashapp:developfrom
hoanle0126:fix/sfw-content-mode-rlock-7293
Open

hoanle0126 wants to merge 1 commit into
stashapp:developfrom
hoanle0126:fix/sfw-content-mode-rlock-7293

Conversation

@hoanle0126

Copy link
Copy Markdown

Description

Config.GetSFWContentMode() acquired i.RLock() and then called i.getBool(SFWContentMode), which also acquires i.RLock() on the same sync.RWMutex. Because Go's sync.RWMutex blocks new RLock calls once a writer is waiting on Lock, any config write arriving between the outer and inner RLock caused GetSFWContentMode and the pending writer to deadlock.

Removing the redundant outer RLock/RUnlock from GetSFWContentMode resolves the recursive read lock and matches the rest of the typed config getters.

Related Issue

fixes: #7293

Testing

Added i.SetInterface(SFWContentMode, i.GetSFWContentMode()) to TestConcurrentConfigAccess (which timed out in <1s prior to the fix) and verified with go test -race ./internal/manager/config/....

Screenshots

NA

Checklist

  • I have read and understood the Contributing document.
  • I have read and understood the AI Usage Policy document.
  • I have made corresponding changes to the documentation (if applicable).

AI Usage Disclosure

  • I have used AI tools to assist with this pull request, and I have disclosed the tools and how I used them below.

Used AI coding assistant to help write the concurrency test reproduction and draft the PR description.

Additional Context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stash freezes (stops answering) when a config write lands while a request is in GetSFWContentMode

1 participant