Apply the Lock-Probe Fixes to cleanup() Too, Fix a Stale Comment - #1106
Conversation
CodeRabbit's review of the develop -> main promotion PR (#1098) found two more real issues, both matching gaps this same PR chain already fixed in hub_read_lock_acquire but left unaddressed in cleanup()'s own separate, pre-existing lock probe: - cleanup() suppressed flock's own stderr on its non-blocking probe and treated any failure as ordinary contention, the same masking bug fixed for hub_read_lock_acquire's own probe. Applied the identical fix: captured stderr distinguishes a real error (surfaced via fail, failing immediately) from ordinary contention (the existing wait message), confirmed live for both paths. - cleanup()'s own exec {lock_fd}>"$DIR/hub.lock" had no explicit success check, the same gap fixed for hub_read_lock_acquire's own open. Checked explicitly now, confirmed live. Also fixed: fetch_hub's own comment claimed hub_read_lock_acquire "runs regardless of --dry-run", but it actually no-ops entirely under --dry-run (never opening a lock at all). Corrected to describe why fetch_hub's own dry-run check exists: without it, the generic "no reader lock held" internal-error message would fire instead of a clear, task-specific one. `shellcheck` and `prose_lint.py` are clean. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
PR Summary by QodoHarden cleanup lock probing and correct dry-run documentation
AI Description
Diagram
High-Level Assessment
Files changed (1) |
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughChangesLock handling
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk:⚪ Minimal · up to This localized cleanup behavior fix is merge-ready after normal checks and review; no actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🟢 Approval recommended
The changes are narrowly scoped, consistent with existing lock-probe patterns in the same script, and improve diagnostics without altering the lock’s intended semantics.
Pull request overview
This PR aligns cleanup()’s lock handling with the hardened behavior already applied to hub_read_lock_acquire, and updates a stale fetch_hub() comment about --dry-run behavior so the diagnostics match the actual control flow.
Changes:
- Update
fetch_hub()comment to reflect thathub_read_lock_acquireno-ops under--dry-run, and explain the purpose of the early--dry-runfailure. - Harden
cleanup()’s exclusive lock acquisition by explicitly checking the lock-fileexecopen and by distinguishing lock contention from realflockerrors (no stderr suppression).
File summaries
| File | Description |
|---|---|
| host-setup/menu.sh | Improves cleanup() lock probing/error reporting and fixes stale --dry-run comment to match current behavior. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Uh oh!
There was an error while loading. Please reload this page.
Code Review by Qodo
1. Probe drops cleanup lock |
| return 1 | ||
| fi | ||
| local probe_err | ||
| if ! probe_err=$(flock -n "$lock_fd" 2>&1); then |
There was a problem hiding this comment.
1. Probe drops cleanup lock 🐞 Bug≡ Correctness
cleanup() runs the nonblocking flock inside command substitution, so an uncontended lock is acquired only by the subshell and released when that subshell exits. The parent then deletes $DIR/hub without an exclusive lock, allowing cleanup to race with readers or a concurrent fetch.
Agent Prompt
## Issue description
The command-substitution probe acquires the lock in a subshell, which releases it before the parent reaches deletion.
## Issue Context
Preserve stderr/error classification without moving the successful `flock` acquisition out of the cleanup process. For example, run `flock -n` directly in the parent and distinguish contention with a dedicated conflict exit code, or capture diagnostics through a mechanism that does not execute `flock` in a subshell.
## Fix Focus Areas
- host-setup/menu.sh[274-288]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
CodeRabbit's review of the develop -> main promotion PR (#1098) found that cleanup()'s own separate, pre-existing lock probe had the same stderr-suppression and missing-exec-check gaps this PR chain already fixed in hub_read_lock_acquire, plus a stale comment claiming hub_read_lock_acquire "runs regardless of --dry-run" when it actually no-ops entirely under --dry-run.
🤖 Generated with Claude Code
Summary by CodeRabbit