Skip to content

fix(runner): release fs watcher lock on removal errors#177

Open
linkdata wants to merge 1 commit into
dnstapir:mainfrom
linkdata:fix/fswatcher-rlock
Open

fix(runner): release fs watcher lock on removal errors#177
linkdata wants to merge 1 commit into
dnstapir:mainfrom
linkdata:fix/fswatcher-rlock

Conversation

@linkdata
Copy link
Copy Markdown

Summary

  • release cleanupFSWatchers RLock with defer on all exit paths
  • add a small removal hook so the error path can be exercised directly
  • assert the mutex is released after a watcher removal failure

Tests

  • go test ./pkg/runner ./...

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 30, 2026

Warning

Rate limit exceeded

@linkdata has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 59 minutes and 49 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7ed6032b-dd4d-4c64-965e-1d4b6b83ca76

📥 Commits

Reviewing files that changed from the base of the PR and between b615285 and d238dc0.

📒 Files selected for processing (2)
  • pkg/runner/runner.go
  • pkg/runner/runner_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 59 minutes and 49 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@linkdata
Copy link
Copy Markdown
Author

Additional context from comment files

These notes were split from the local markdown comment files and attached here because they describe this PR's change.

FS Watcher Mutex Leak

  • Bug: In cleanupFSWatchers(), an early return statement inside the RLock scope at lines 1003–1005 exited the function without calling RUnlock(), leaking the read lock.
  • Impact: Any subsequent attempt to acquire the write lock on fsWatcherMutex (e.g., in configureFSWatchers) would block indefinitely because the read lock was never released.
  • Fix: Added defer edm.fsWatcherMutex.RUnlock() immediately after RLock() and removed the explicit RUnlock() call that was only reachable on the success path.
  • Reasoning: Using defer ensures the lock is always released, even on error return paths, preventing mutex deadlocks.
  • Tests: Added TestCleanupFSWatchersReleasesLockOnError which calls cleanupFSWatchers() and then verifies fsWatcherMutex.TryLock() succeeds, confirming the read lock was released.

@linkdata linkdata marked this pull request as ready for review April 30, 2026 12:12
@linkdata linkdata requested a review from a team as a code owner April 30, 2026 12:12
@jschlyter jschlyter added the ai AI was used to write contributed code label Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai AI was used to write contributed code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants