Repository navigation
fix(gateway): recover container startup after a crash - #205709
Conversation
Co-authored-by: RomneyDa <[email protected]>
Worked on by: - @RomneyDa Co-authored-by: RomneyDa <[email protected]> OpenClaw-Publication: 51d3c870-57c0-45d2-b1c7-601c5a9fd876
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Co-authored-by: RomneyDa <[email protected]>
|
Codex review: needs maintainer review before merge. What this changesRestore automatic Gateway recovery after container crashes using container identity and expired heartbeats while retaining bounded waits and hidden confirmed recovery. Example: A replacement container starts on the same persistent volume after the previous Gateway receives SIGKILL.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR addresses a confirmed container restart failure that remains on main; no blocking correctness or security defect was found. Reviewed head: Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway startup and Doctor admission inspect physical ownership files and persisted Gateway leases before admitting database access and starting the server. flowchart TD
A[Container entrypoint] --> B[Doctor and Gateway admission]
B --> C[Shared owner classifier]
C --> D[Physical ownership files]
C --> E[Gateway owner lease]
D --> F[Admitted Gateway startup]
E --> F
Technical reviewBest possible solution: Use the existing shared ownership classifier for automatic container recovery, preserve bounded live-holder refusal, and retain confirmed recovery for unsupported identities. Do we have a high-confidence way to reproduce the issue? The linked report supplies SIGKILL/restart steps, current main establishes the refusal path, and the PR supplies after-fix container captures; this review executed no target code. Is this the best way to solve the issue? Centralizing the recovery decision in the existing classifier is a focused fix, with the changed paused-owner policy explicitly accepted and documented by the maintainer-authored PR. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 254f60242899. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +24, Tests +59, Docs -63, Other +2. Total +22 across 30 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed November 26, 2026, 1:17 AM ET / 06:17 UTC (Revision 4). |
Keep existing SQLite and PostgreSQL compatibility recovery without advertising it in help or diagnostic next steps. Co-authored-by: RomneyDa <[email protected]>
Worked on by: - @RomneyDa Co-authored-by: RomneyDa <[email protected]> OpenClaw-Publication: bc9cb3f9-1809-44db-9515-c11c4f6af0fa
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
A foreign-namespace wait now uses the role's ordinary deadline (five minutes for Gateway startup, 95 seconds for Doctor) instead of waiting indefinitely on a renewing owner. This removes the Doctor cancellation check that only the unbounded wait needed, and restores ordinary contention for an unparseable owner record. Co-authored-by: RomneyDa <[email protected]>
Startup and Doctor wait up to 95 seconds for an owner in another PID namespace, as before. That covers heartbeat expiry after a crash; a still-renewing owner keeps the existing bounded refusal. Co-authored-by: RomneyDa <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
* fix(gateway): recover container startup after a crash Co-authored-by: RomneyDa <[email protected]> * fix(gateway): recover container startup after a crash Worked on by: - @RomneyDa Co-authored-by: RomneyDa <[email protected]> OpenClaw-Publication: 51d3c870-57c0-45d2-b1c7-601c5a9fd876 * fix(gateway): keep legacy lock guidance and prune stale ratchet entry Co-authored-by: RomneyDa <[email protected]> * fix(gateway): retain confirmed recovery as a hidden diagnostic Keep existing SQLite and PostgreSQL compatibility recovery without advertising it in help or diagnostic next steps. Co-authored-by: RomneyDa <[email protected]> * Publish openclaw/docker-heartbeat Worked on by: - @RomneyDa Co-authored-by: RomneyDa <[email protected]> OpenClaw-Publication: bc9cb3f9-1809-44db-9515-c11c4f6af0fa * fix(gateway): keep lock waits bounded and contention unchanged A foreign-namespace wait now uses the role's ordinary deadline (five minutes for Gateway startup, 95 seconds for Doctor) instead of waiting indefinitely on a renewing owner. This removes the Doctor cancellation check that only the unbounded wait needed, and restores ordinary contention for an unparseable owner record. Co-authored-by: RomneyDa <[email protected]> * fix(gateway): keep the foreign-owner wait at its original bound Startup and Doctor wait up to 95 seconds for an owner in another PID namespace, as before. That covers heartbeat expiry after a crash; a still-renewing owner keeps the existing bounded refusal. Co-authored-by: RomneyDa <[email protected]> --------- Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 2dbd121) Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
* fix(gateway): recover container startup after a crash Co-authored-by: RomneyDa <[email protected]> * fix(gateway): recover container startup after a crash Worked on by: - @RomneyDa Co-authored-by: RomneyDa <[email protected]> OpenClaw-Publication: 51d3c870-57c0-45d2-b1c7-601c5a9fd876 * fix(gateway): keep legacy lock guidance and prune stale ratchet entry Co-authored-by: RomneyDa <[email protected]> * fix(gateway): retain confirmed recovery as a hidden diagnostic Keep existing SQLite and PostgreSQL compatibility recovery without advertising it in help or diagnostic next steps. Co-authored-by: RomneyDa <[email protected]> * Publish openclaw/docker-heartbeat Worked on by: - @RomneyDa Co-authored-by: RomneyDa <[email protected]> OpenClaw-Publication: bc9cb3f9-1809-44db-9515-c11c4f6af0fa * fix(gateway): keep lock waits bounded and contention unchanged A foreign-namespace wait now uses the role's ordinary deadline (five minutes for Gateway startup, 95 seconds for Doctor) instead of waiting indefinitely on a renewing owner. This removes the Doctor cancellation check that only the unbounded wait needed, and restores ordinary contention for an unparseable owner record. Co-authored-by: RomneyDa <[email protected]> * fix(gateway): keep the foreign-owner wait at its original bound Startup and Doctor wait up to 95 seconds for an owner in another PID namespace, as before. That covers heartbeat expiry after a crash; a still-renewing owner keeps the existing bounded refusal. Co-authored-by: RomneyDa <[email protected]> --------- Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 2dbd121) Release adaptation: remove the release-local spelling of the superseded shouldReclaimGatewayLock helper, keeping unrelated Gateway ownership and release behavior. Backport review: #205821 follows this owner-lease change; #205812 shares only Docker docs and is not a startup prerequisite. Co-authored-by: vincentkoc <[email protected]> Co-authored-by: RomneyDa <[email protected]>
* fix(gateway): avoid the Windows boot probe stall at startup Co-authored-by: RomneyDa <[email protected]> * test(state): narrow the mocked boot probe call before reading it Co-authored-by: RomneyDa <[email protected]> * fix(state): return undefined explicitly from the boot provenance guard Co-authored-by: RomneyDa <[email protected]> --------- Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit e088e2e) Backport review: follows #205709 in the owner lease, preserving the shorter heartbeat and the release owner publication path. No later overlapping upstream commits at the pinned scan end. Co-authored-by: vincentkoc <[email protected]> Co-authored-by: RomneyDa <[email protected]>
* fix(gateway): recover container startup after a crash Co-authored-by: RomneyDa <[email protected]> * fix(gateway): recover container startup after a crash Worked on by: - @RomneyDa Co-authored-by: RomneyDa <[email protected]> OpenClaw-Publication: 51d3c870-57c0-45d2-b1c7-601c5a9fd876 * fix(gateway): keep legacy lock guidance and prune stale ratchet entry Co-authored-by: RomneyDa <[email protected]> * fix(gateway): retain confirmed recovery as a hidden diagnostic Keep existing SQLite and PostgreSQL compatibility recovery without advertising it in help or diagnostic next steps. Co-authored-by: RomneyDa <[email protected]> * Publish openclaw/docker-heartbeat Worked on by: - @RomneyDa Co-authored-by: RomneyDa <[email protected]> OpenClaw-Publication: bc9cb3f9-1809-44db-9515-c11c4f6af0fa * fix(gateway): keep lock waits bounded and contention unchanged A foreign-namespace wait now uses the role's ordinary deadline (five minutes for Gateway startup, 95 seconds for Doctor) instead of waiting indefinitely on a renewing owner. This removes the Doctor cancellation check that only the unbounded wait needed, and restores ordinary contention for an unparseable owner record. Co-authored-by: RomneyDa <[email protected]> * fix(gateway): keep the foreign-owner wait at its original bound Startup and Doctor wait up to 95 seconds for an owner in another PID namespace, as before. That covers heartbeat expiry after a crash; a still-renewing owner keeps the existing bounded refusal. Co-authored-by: RomneyDa <[email protected]> --------- Co-authored-by: RomneyDa <[email protected]>
2026.11.11 is the maintenance release of the 2026.11.10 line (no config, schema or CLI changes; state 40 / agent 42 as before). - Dockerfile: OPENCLAW_VERSION=2026.11.11, NPM_BEFORE=2026-11-28T04:06:00Z. - oc-patches/2026.11.11 replaces the 2026.11.10 set (never shipped): the same five patches, carried to the new chunk names; the patched modules are byte-identical apart from chunk names in imports. The doctor patch stays: the statement is unchanged upstream. - Node harnesses renamed and pointed at the new chunks. - Docs, changelog, security notes, translations: bundled version, publish times, and the start after an unclean stop (gateway lock takeover after 90 s, openclaw/openclaw#205709). Tests: pytest 1007 passed / 3 skipped, wrapper 272, node harnesses 31, test_real_package against the unpacked 2026.11.11 package. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01BaA7Y516JjzXvphq8hMwwt
Closes #203932
What Problem This Solves
After a Gateway container is killed, a new Gateway on the same persistent volume cannot inspect the old PID from its new PID namespace. Before this change it waited about 95 seconds and then failed with
GatewayLockNamespaceErroreven when the old Gateway was gone, and the only way out was the manualopenclaw gateway recover-lockprocedure.User Impact
recover-lockbackend stays available as a hidden diagnostic and is no longer advertised in startup, update, or daemon guidance.Why This Change Was Made
Filesystem locks, persisted Gateway owner leases, and SQLite/Doctor admission now share one classification. A different Linux PID namespace counts as dead if (a) the record's hostname is the current container's 12-hex default hostname inside a container, or (b) the lock's heartbeat (sidecar mtime, renewed every 15 seconds) is more than 90 seconds old. The Gateway owner lease now records the same 15-second heartbeat interval so lease age agrees with the file lock. Wait bounds, cancellation, and refusal types match the base.
Accepted edge cases, with no added code: a container paused for more than 90 seconds can resume next to its replacement until its next restart, because this change adds no self-fencing (SQLite's native locking still protects the database file). Two different containers given the same custom 12-hex hostname on one volume would be treated as the same container. Production/docs: +139/−176. Tests: +129/−70.
Error surfaces
Full diff against merge-base
90ba7624dbdd. Each row is a new or changed failure path. "Healthy" means a single Gateway, or a normal update, on one host.acquireGatewayLock)GatewayLockErroras base. Only the log text changed2505c29andac69712signal.throwIfAborted()inassertCurrent2505c29). Only the removed unbounded wait needed itGatewayLockNamespaceErrorinstead of contention2505c29). Contention handling is the same as basegateway.state.lock) reclaim: unknown owner returns "not stale" instead of throwingGatewayLockError), different messagehasVerifiedLiveSqliteOwnerreturns false for a dead-classified ownergateway recover-lockhidden;--jsondropscommand; guidance text in legacy-lock, update-refusal, and daemon-diagnostic messagesNo new throw, exit, refusal, rollback trigger, or tightened validation remains in Gateway startup or update/Doctor admission.
Evidence (exact head
ac69712a4729)All runs used private rootless Podman 5.7.0 (task-owned
--root/--runroot,--network none,--http-proxy=falsefor builds) and synthetic config/state. The candidate is the npm package built fromac69712a4729withscripts/package-openclaw-for-docker.mjs(build-info commitac69712a4729d751…, buildId2026.11.10-ac69712a4729-2026-11-26T05-55-50.847Z).[email protected]was installed globally and run asopenclaw-gateway.serviceviaopenclaw gateway install.update.runtargeted the candidate through a loopback registry fixture. For the updater, the candidate's package version was relabeled to 2026.11.11; dist and build-info commit/buildId are unchanged. The run endedsucceeded/finishedin 106 s (recorded downtime 52 s). Ledger:candidate-admissionok,service-stopok,openclaw doctorexit 0 (maintenance.begin 0.6 s,schema-admission 0.1 s),post-update verificationok. After the update the service reported the candidate buildId with/healthz200,/readyz200, and authenticatedhealthRPC ok.openclaw gateway restartserved again in 11 s,systemctl --user restartin 9 s, and SIGKILL of MainPID (systemd restart) in 13 s. Each came back with the same buildId, a new bootId, and healthz/readyz/health RPC ok. The unit journal had 0 ownership refusals.tini→docker-entrypoint.mjs→ Doctor → Gateway), shared named volume:/readyz200 with health RPC ok throughout.doctor --fixbeside a live Gateway: bounded refusal after 97 s (cannot verify Gateway ownership). The serving Gateway was unaffected.Unit tests cover additional rows but are not counted as proof here. These are covered only by unit tests: macOS/Windows legacy namespace-less locks, custom-hostname containers, a paused container overlapping its replacement, PostgreSQL lease recovery, mixed-version lease ages, and the restoration-reservation path.
Redacted terminal capture (exact head)
Worked on by