Environment
- GJC: 0.13.2
- Bun: 1.3.14
- OS: Windows 11 Pro 10.0.26200 x64
Problem
gjc repeatedly fails during startup:
Error: Failed to acquire lock for
C:\Users\<user>\.gjc\agent\sdk\sessions\index.jsonl
after 600 attempts
The lock owner is a live detached SDK broker process. Because the owner is alive, stale-lock recovery correctly refuses to remove the lock, but the broker does not release it before other launches exhaust the full 600-attempt budget.
Reproduction
- Start one or more GJC sessions on Windows.
- Leave the SDK broker running long enough for heartbeat, audit, or compaction work to execute.
- Start another
gjc.
- Startup waits through all 600 lock attempts and crashes.
This reproduced repeatedly across several broker PIDs.
Evidence
One recurrence had this lock metadata:
{"pid":22076,"start_time":"unknown","timestamp":1786683086258}
PID 22076 was still alive and broker.json heartbeat continued updating, but index.jsonl.lock remained held long enough for another GJC process to exhaust the lock budget. The crash log recorded the same failure from multiple launch PIDs.
The released v0.13.2 source still contains the read-only snapshot fsync fixed by #4254. Applying the equivalent writable-handle change locally allowed snapshot rotation to complete, but the same broker later held the canonical index lock indefinitely again without creating a new snapshot temp file.
This suggests another awaited operation inside the locked heartbeat/audit/append path can stall on Windows. The exact operation still needs instrumentation; the lock timeout is the observed downstream failure.
Local diagnostic workaround
After stopping the stuck broker, I locally skipped Windows FileHandle.sync() calls in the normal session-index append/snapshot paths and skipped the Windows directory-sync barrier. Two complete GJC startup probes separated by 70 seconds then succeeded, and the lock directory was absent afterward:
This workaround weakens durability and is not proposed as the production fix. It only narrows the suspected stall to a Windows sync operation executed while the machine-global session-index lock is held.
Expected behavior
- No filesystem await should hold the machine-global session-index lock indefinitely.
- A live but wedged broker must not block every new GJC launch.
- Windows durability should remain intact where supported.
- Unsupported or hanging sync operations need bounded handling and diagnostics identifying the exact operation.
- Startup should recover without manually killing the broker or deleting lock state.
Suggested investigation
Instrument each awaited operation inside the locked session-index append, audit, snapshot, rotation, and directory-sync paths. Add a real-Windows regression that runs periodic heartbeat/audit/compaction work and concurrently launches a second session beyond one sweep interval.
Related: #4250, #4254, #4272.
Environment
Problem
gjcrepeatedly fails during startup:The lock owner is a live detached SDK broker process. Because the owner is alive, stale-lock recovery correctly refuses to remove the lock, but the broker does not release it before other launches exhaust the full 600-attempt budget.
Reproduction
gjc.This reproduced repeatedly across several broker PIDs.
Evidence
One recurrence had this lock metadata:
{"pid":22076,"start_time":"unknown","timestamp":1786683086258}PID 22076 was still alive and
broker.jsonheartbeat continued updating, butindex.jsonl.lockremained held long enough for another GJC process to exhaust the lock budget. The crash log recorded the same failure from multiple launch PIDs.Relationship to #4250 / #4254
The released v0.13.2 source still contains the read-only snapshot fsync fixed by #4254. Applying the equivalent writable-handle change locally allowed snapshot rotation to complete, but the same broker later held the canonical index lock indefinitely again without creating a new snapshot temp file.
This suggests another awaited operation inside the locked heartbeat/audit/append path can stall on Windows. The exact operation still needs instrumentation; the lock timeout is the observed downstream failure.
Local diagnostic workaround
After stopping the stuck broker, I locally skipped Windows
FileHandle.sync()calls in the normal session-index append/snapshot paths and skipped the Windows directory-sync barrier. Two complete GJC startup probes separated by 70 seconds then succeeded, and the lock directory was absent afterward:This workaround weakens durability and is not proposed as the production fix. It only narrows the suspected stall to a Windows sync operation executed while the machine-global session-index lock is held.
Expected behavior
Suggested investigation
Instrument each awaited operation inside the locked session-index append, audit, snapshot, rotation, and directory-sync paths. Add a real-Windows regression that runs periodic heartbeat/audit/compaction work and concurrently launches a second session beyond one sweep interval.
Related: #4250, #4254, #4272.