fix(doctor): emit accurate --break-lock hint for non-sync stale locks#1553
Open
Sanjays2402 wants to merge 1 commit into
Open
fix(doctor): emit accurate --break-lock hint for non-sync stale locks#1553Sanjays2402 wants to merge 1 commit into
Sanjays2402 wants to merge 1 commit into
Conversation
The stale_locks check hard-coded 'gbrain sync --break-lock' for every stale row, but 'gbrain sync --break-lock' only handles 'gbrain-sync:*' keys. For 'gbrain-cycle' (and per-source 'gbrain-cycle:<source>') locks the suggested command silently no-ops with 'Lock gbrain-sync:default is not held', leaving operators with no shipped path to clear the lock. Branch the hint by lock-id prefix: keep the sync hint for sync locks, and for unrecognized kinds (cycle, future kinds) print the SQL fallback DELETE so the message is honest instead of misleading. The DELETE id is single-quote-escaped to keep the printed snippet safe to copy. Pure formatter change in the doctor output path; no DB or CLI surface behavior changes. Fixes garrytan#1534
|
Confirmed this same failure mode on a real local Postgres brain after upgrading to What I saw: Following the hint did not clear the lock because I cleared the expired Also agree with the PR body that #1591 is the right follow-up for a real cycle-lock breaker CLI; this PR is still valuable as the minimum correction because current doctor output actively points at the wrong command. |
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.
Summary
Fixes #1534.
doctor'sstale_lockscheck hard-codedgbrain sync --break-lockas the recovery hint for every stale row. But that command, persync.ts, only handlesgbrain-sync:*keys — it silently no-ops ongbrain-cycle(and per-sourcegbrain-cycle:<source>) locks withLock gbrain-sync:default is not held (nothing to break)., leaving operators with no shipped path to clear the lock.Fix
Extracted a small
formatStaleLockBreakHint(lockId)helper that branches on the lock-id prefix:gbrain-sync:<src>→gbrain sync --break-lock --source <src>gbrain-sync→gbrain sync --break-lockgbrain-cycle,gbrain-cycle:<src>, future kinds) → an honest SQL-fallback hint:manual clear required (no CLI breaker for <id>): DELETE FROM gbrain_cycle_locks WHERE id = '<id>';The
idis single-quote-escaped so the printed snippet is safe to copy verbatim.Why this shape instead of shipping a new CLI breaker
The issue suggests also adding
gbrain dream --break-lockorgbrain admin break-lock <name>. That's the right next step but it's a CLI-surface decision (PID liveness, force-break semantics, cross-host guards) that's better landed on its own with proper tests. This PR is the minimum honest-hint change so thatdoctorstops actively misleading operators today.Risk
Pure formatter change inside the doctor output builder. No DB writes, no new CLI surface, no behavior change for the existing
gbrain-sync:*cases. Output text changes for cycle locks only.Test plan
No unit tests target this string today. Verified the helper output by extracting it into a Node REPL (covers sync, sync-with-source, cycle, cycle-with-source, and single-quote-in-id):
Did not run the full
bun test/bun run verifysuite locally (no Postgres + Bun on this machine); CI will cover.