Skip to content

doctor stale_locks: --break-lock hint hard-codes <code>gbrain sync</code> even when lock is <code>gbrain-cycle</code> #1534

@Mr-B-1

Description

@Mr-B-1

Summary

When doctor reports a stale gbrain-cycle lock, it advises gbrain sync --break-lock — but that command can only address gbrain-sync:* locks. There is no shipped CLI handler for gbrain-cycle locks, so the only way to clear them is direct SQL into gbrain_cycle_locks.

Repro

  1. Have a dream cycle die mid-run (process crash, OOM, sigkill) so the gbrain-cycle row stays in gbrain_cycle_locks past its TTL
  2. Run gbrain doctor. The stale_locks check correctly detects it and prints:
    gbrain-cycle (pid <N> on <host>, age <age>) → gbrain sync --break-lock
  3. Run the suggested gbrain sync --break-lock
  4. Output: Lock gbrain-sync:default is not held (nothing to break).
  5. The cycle lock is unchanged, and subsequent cycle_freshness checks continue to FAIL

Root cause

src/commands/doctor.ts:1670 hard-codes the hint:

const breakHint = source ? `gbrain sync --break-lock --source ${source}` : `gbrain sync --break-lock`;

src/commands/sync.ts:556 scopes --break-lock to sync locks only:

`gbrain sync --break-lock --source ${lockKey.slice('gbrain-sync:'.length)}`

There is no analogous handler for gbrain-cycle (or any other lock prefix).

Tested workarounds that did not work

Suggested fixes

  1. Doctor: branch the hint based on the lock_name prefix (e.g. gbrain-cycle → suggest the cycle breaker)
  2. CLI: ship a handler. Either:
    • gbrain dream --break-lock (route by command that owns the lock kind), or
    • gbrain admin break-lock <lock-name> (kind-agnostic)
  3. Both should reuse the same liveness + force-break semantics as sync.tss D3 implementation (PID check, TTL window, cross-host safety, --force-break-lock opt-out)

Environment

  • gbrain v0.41.14.0
  • Hit on gbrain-cycle after a dream cycle died at 09:00 UTC; lock TTL expired at 09:30 UTC; PID 3396714 was dead per ps -p at 21:30 UTC
  • Stale lock blocked all subsequent dream/cycle runs (cycle_freshness FAIL: "last cycled 30h ago")

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions