Release state-backend instance lock on graceful shutdown (avoid ~5min stall on redeploy) #190
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The state-backend instance lock (#153) is only released by stale-timeout expiry (5m after last heartbeat), never proactively on shutdown. As a result, any redeploy where the outgoing pod held the lock stalls the incoming pod for up to 5 minutes.
Observed (dogfood, v0.6.6, 2026-08-10)
During an OIDC-issuer config change +
rollout restartofcairn-enc, the new pod crash-looped with:The previous instance had acquired the lock moments before being replaced and did not release it on
SIGTERM, so the new instance correctly refused to start (two-writer guard doing its job) — but had to wait out the full 5m staleness window before it could boot.Impact
Proposed fix
On graceful shutdown (
SIGTERM/SIGINT), release the instance lock as part of the shutdown sequence — delete/clear the lock object in the state backend (.cairn-state/) held by this instance before exiting. Then a rolling replacement finds a free lock immediately.Design considerations:
SIGKILL) where no graceful release runs — this issue is about adding proactive release, not removing the safety net.strategy: Recreate(as the dogfood uses for RWO-on-NFS safety) the old pod is fully terminated before the new one starts, so a clean release onSIGTERMfully closes the gap. With surge-style strategies the guard still (correctly) blocks overlap.Acceptance
rollout restart(Recreate) brings the new podReadyin seconds, with noinstance lock: refusing to startin the new pod's logs.Notes
Filed while waiting out exactly this 5m window on the dogfood. Related: #153 (state-in-backend + instance lock).