Skip to content

fix: distinguish lock creation failures from contention - #5798

Open
florinteodorescu wants to merge 1 commit into
kunchenguid:mainfrom
florinteodorescu:fix/procevent-lock-create-errors
Open

florinteodorescu wants to merge 1 commit into
kunchenguid:mainfrom
florinteodorescu:fix/procevent-lock-create-errors

Conversation

@florinteodorescu

Copy link
Copy Markdown

Intent

Stop the recurring Bash SIGSEGVs observed on this Omarchy machine, explain the root cause, and keep Firstmate safe: core evidence showed process-event reconciliation recursively trying longer .steal lock paths when lock-owner storage could not be created. Treat real lock-creation failures distinctly from ordinary lock contention so valid waiters and stale-lock recovery still work; add behavior regressions for both. The user specifically cautioned against breaking Firstmate and requested independent Sol review before an upstream PR.

What Changed

  • Distinguish lock-owner directory creation failures from ordinary contention, preventing failed recovery from recursively extending .steal paths.
  • Use a process-event lock wait that retries contention but returns owner-storage creation errors.
  • Add regressions for live steal-lock contention, owner-storage creation failure, and releasing .steal after failed stale recovery.

Risk Assessment

✅ Low: The change is narrowly scoped to propagating lock-owner directory creation failures while preserving contention retries and stale-lock cleanup.

Testing

The focused lock suite passed, and isolated live CLI runs confirmed stale-recovery creation errors return cleanly with .steal removed while ordinary live contention waits and then registers successfully.

  • Live validation: ✅ go - 2 of 2 scenarios driven live against the product
Scenario Result Live Evidence
Registering a source fails during stale-lock recovery when owner storage cannot be recreated; the CLI returns a lock error and leaves neither lock nor .steal behind. ✅ pass live Live process-event source-lock CLI transcript; tests/fm-watcher-lock.test.sh
Registering a source while a live .steal holder has temporarily removed the primary lock waits, then succeeds after the holder releases it. ✅ pass live Live process-event source-lock CLI transcript; tests/fm-watcher-lock.test.sh
Evidence: Live process-event source-lock CLI transcript

Source: Live process-event source-lock CLI transcript

scenario=stale-recovery-owner-storage-failure cli_exit=1 output=error: cannot lock the source
lock_creation_sequence=primary-owner-attempt-1;steal-owner-directory-created;primary-owner-attempt-2;forced-primary-recreation-failure
primary_lock=absent steal_mutex=absent
scenario=live-steal-contention-with-missing-primary cli_exit=0 output=registered: live-contention (quota) waiter_retried=yes registration=persisted steal_mutex=absent
- Outcome: 🔧 1 issue found → no changes applied ✅ across 2 runs (22m33s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

🔧 **Rebase** - 1 issue found → auto-fixed ✅
  • ⚠️ bin/fm-wake-lib.sh - merge conflict rebasing onto origin/main

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Review** - passed

✅ No issues found.

🔧 **Test** - 1 issue found → no changes applied ✅
  • ⚠️ live validation verdict: inconclusive (3 of 4 scenarios were driven live against the product); untested: If primary lock creation fails during stale recovery after acquiring .steal, return the creation error and release the mutex.
  • Live validation: ⚠️ inconclusive - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Register a source when lock-owner storage is unwritable; the CLI returns a source-lock error promptly without creating lock paths. ✅ pass live Live process-event CLI lock scenarios
Register while another process owns the source lock; the CLI waits for release and persists the registration. ✅ pass live Live process-event CLI lock scenarios
Register over a stale dead-owner lock; the CLI reclaims it and completes registration. ✅ pass live Live process-event CLI lock scenarios
If primary lock creation fails during stale recovery after acquiring .steal, return the creation error and release the mutex. ⏸️ untested no The prior payload cites only bash tests/fm-watcher-lock.test.sh and marks this scenario live=false, so it does not establish a result against the live product.
  • bash tests/fm-watcher-lock.test.sh
  • Live CLI registration with read-only lock-owner storage, bounded by timeout 4
  • Live CLI registration while a separate process held the source lock, then released it
  • Live CLI registration against a dead-owner lock with FM_LOCK_STALE_AFTER=0
  • Verified the worktree remained clean after testing

🔧 No changes applied.
✅ Re-checked - no issues remain.

  • Live validation: ✅ go - 2 of 2 scenarios driven live against the product
Scenario Result Live Evidence
Registering a source fails during stale-lock recovery when owner storage cannot be recreated; the CLI returns a lock error and leaves neither lock nor .steal behind. ✅ pass live Live process-event source-lock CLI transcript; tests/fm-watcher-lock.test.sh
Registering a source while a live .steal holder has temporarily removed the primary lock waits, then succeeds after the holder releases it. ✅ pass live Live process-event source-lock CLI transcript; tests/fm-watcher-lock.test.sh
  • tests/fm-watcher-lock.test.sh
  • Live bin/fm-procevent.sh register quota live-failure -- true with owner-directory creation fault-injected on stale recovery
  • Live bin/fm-procevent.sh register quota live-contention -- true while a process held the real .steal lock and then released it
  • git diff --check d1a332cdd4b9483ae0c43e9cf33684fadce28869 76091c68c586376cef128b72730da1dc13d01ef0
✅ **Document** - passed

✅ No issues found.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)

🔧 No changes applied.
1 warning still open:

  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

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.

1 participant