openclaw-windows-node icon indicating copy to clipboard operation
openclaw-windows-node copied to clipboard

[Bug] cron permanently UNAVAILABLE: stale cron-authority lock held by an orphaned Gateway process, `doctor --fix` cannot clear it

Open 168062576-tech opened this issue 1 month ago • 4 comments

Summary

On Windows (Companion 2026.9.8-1 / Gateway 2026.10.6), the automation (cron) subsystem never starts and stays UNAVAILABLE for the whole life of the Gateway process:

  • cron.status / cron.list → errorCode=UNAVAILABLE, Cron receipt authority is unavailable; wait for Gateway settlement or restart.
  • [cron] failed to start: … once per boot, then [cron/maintenance] Cron maintenance failed … every 60 s
  • [plugins] memory-core: dreaming cron reconcile failed … every 60 s

The cause is a lock file whose owning process is dead, but whose PID was recycled by a live, unrelated process, so the "is the owner still alive" check keeps passing and every new Gateway abandons the authority.

Environment

Companion 2026.9.8-1 (OpenClaw.Tray.WinUI.exe 2026.9.8.0)
Gateway 2026.10.6 (fe06181), managed local Gateway in the isolated (MXC) session
OS Windows 11 10.0.26200.9711 x64
State C:\Users\<agent>\.openclaw\state\openclaw.sqlite

What we see

Lock file C:\Users\<agent>\.openclaw\state\openclaw.sqlite.cron-authority.lock:

{
  "pid": 21100,
  "createdAt": "2026-10-28T04:58:27.126Z",
  "starttime": 1793163133346
}

PID 21100 is alive — but it is a previous Gateway process (started 12:52 local), not the current one, and it does not even own the Gateway port any more (the current Gateway is a different PID listening on 49682). It simply never exited, and it has been holding the authority since 04:58Z.

Every subsequent Gateway boot therefore fails:

13:31:46.915 [plugins] memory-core: dreaming startup reconciliation failed:
            file lock timeout for C:\Users\<agent>\.openclaw\state\openclaw.sqlite.cron-authority
13:31:52.203 [cron] failed to start: Error: Cron receipt authority is unavailable; wait for Gateway settlement or restart.

and never recovers until the lock owner is killed.

Secondary (possibly related) observation: cron loses a race against agent-DB startup preparation

In the same boots, cron's first start attempt happens ~1–11 s before agent-database preparation finishes, and the failure is terminal for that process:

13:31:43.809 [cron/maintenance] Cron maintenance deferred until agent database startup preparation completes
13:31:43.814 [state/agent-admission] agent database startup preparation still running agentId=main phase=readiness elapsedMs=116252 phaseElapsedMs=56402
13:31:52.203 [cron] failed to start: …
13:31:53.586 [state/agent-admission] agent database recovered after background inspection and preparation   ← 1.4 s later

Even when the lock is clear, cron apparently does not retry after preparation completes, so a 1-second miss costs the whole process lifetime. Worth making the start attempt idempotent/retryable after settlement.

openclaw doctor --fix does not help

Running openclaw doctor --fix (also openclaw doctor) does not clear the lock, because it repairs stored state and does not consider a lock file whose PID belongs to a live process. openclaw doctor itself also hangs for >4 minutes in this state (no output), so it is not usable as a recovery path either.

Why it is hard to recover from the Companion

The orphaned Gateway runs in the isolated session under a different Windows account, so a non-elevated shell cannot terminate it:

taskkill /F /PID 21100  →  ERROR: The process with PID 21100 could not be terminated. Reason: Access is denied.
Stop-Process -Id 21100  →  (no effect)

Restarting the Companion / the Gateway does not help: the new Gateway sees a live lock owner and gives up.

Workaround that works

  1. Run elevated: Stop-Process -Id <pid-from-lock-file> -Force
  2. Delete …\state\openclaw.sqlite.cron-authority.lock
  3. Restart the Companion (new Gateway can now take the authority)

Suggested fixes

  1. Validate ownership properly — compare the recorded starttime (process start time) and a per-boot nonce, not just PID liveness. Both fields are already in the lock file (starttime), so a mismatch should be treated as stale.
  2. Reclaim automatically rather than failing forever: if the recorded process is not a Gateway supervisor child of this session, or its start time differs, take over the lock (with a log line).
  3. Retry cron startup after agent database startup preparation completes (and after any settlement), instead of failing terminally on the first attempt.
  4. Teach doctor/doctor --fix to detect and clear a stale cron-authority lock, and make doctor not hang when the authority is unavailable.
  5. Consider surfacing this in status/health as "automations unavailable: stale lock (pid N)" so it is diagnosable without reading the Gateway log.

168062576-tech avatar Oct 28 '26 05:10 168062576-tech

Codex review: this still needs some work.

Summary This issue establishes a released-build automation outage, and no verified change demonstrates recovery from the competing cron authority owner.

Reproducibility: The report provides affected releases, errors, and successful manual recovery, but current-main reproduction and a direct live owner-identity comparison are missing; no tests or runtime were run in this read-only review, and WinApp CLI was unavailable.

Maintainer decision needed

  • Question: Should the next investigation reproduce package process retirement and cron authority recovery together, or first request a sanitized current-release process-identity comparison?
  • Recommendation: Reproduce the ownership boundary: Use an owned isolated Gateway to distinguish a live previous owner, a dead owner, and PID reuse, then verify cron recovery.
  • Why: The released outage is specific, but the follow-up inferred owner identity from timing and current lifecycle improvements do not prove scheduler recovery.

Next step Establish a failing process-retirement or cron authority-recovery regression before implementing a safe Companion Doctor or Fix path.

Review details

Best possible solution:

Restore safe authority recovery in its owning producer and expose a Companion Doctor or Fix action that verifies automation availability.

Do we have a high-confidence way to reproduce the issue?

The report provides affected releases, errors, and successful manual recovery, but current-main reproduction and a direct live owner-identity comparison are missing; no tests or runtime were run in this read-only review, and WinApp CLI was unavailable.

Is this the best way to solve the issue?

Repair the first failing lifecycle or authority boundary after establishing a regression; unconditional lock deletion, listener-based process termination, and speculative retries are not justified by the evidence.

AGENTS.md: found and applied where relevant.

Remaining risk / open question:

  • The report does not isolate whether process retirement, stale-lock reclamation, or scheduler startup retry first violates its contract.
  • A missing listener or an old PID does not authorize terminating a process or deleting its authority lock.

Codex review notes: model internal, reasoning medium; reviewed against b762c8dc12a8.

Label changes

Label changes:

  • add issue-rating: 🦪 silver shellfish: Current issue advisory state selects this label.
  • remove issue-rating: 🦐 gold shrimp: Current issue advisory state no longer selects this label.
  • remove clawsweeper:needs-info: Current issue advisory state no longer selects this label.

Label justifications:

  • P0: The reported installed automation workflow remains unusable after ordinary restarts and recovery requires elevated process termination and state-file removal.
  • impact:ux-release-blocker: The affected community user has no demonstrated in-product recovery path for restoring automations.
Evidence reviewed

Acceptance criteria:

  • Establish a failing regression for the isolated ownership or recovery defect before opening a repair PR.
  • ./build.ps1
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore
  • dotnet test ./tests/OpenClaw.Connection.Tests/OpenClaw.Connection.Tests.csproj --filter FullyQualifiedName~IsolatedGatewayRuntimeTests

What I checked:

  • Released-build outage and successful manual recovery: The reporter's November 12 follow-up identifies Companion 2026.11.1.0 and Gateway package 2026.11.100.0, reports an older live Gateway holding authority, and reports cron becoming enabled after process termination, lock removal, and restart. The start-time conclusion was inferred from timing rather than a captured comparison with the live process.
  • Current default branch and cron ownership: The checkout matches the GitHub main reference. Cron list and status are Gateway RPCs; these client methods do not implement authority acquisition or stale-lock reclamation. (src/OpenClaw.Shared/Cron/CronGatewayRequests.cs:18, b762c8dc12a8)
  • Restart confirms package stop, without proving cron recovery: Explicit restart delegates stop to the package and requires stopped or not-started status before starting again. Release intentionally leaves the package service running, so a surviving process alone is not evidence of an orphan. (src/OpenClaw.Connection/NativeGateway/IsolatedGatewayRuntime.cs:633, b762c8dc12a8)
  • Existing lifecycle coverage: Tests preserve the package service across Companion release and verify explicit restart without acquiring detach ownership; these assertions do not exercise a real competing cron lock owner. (tests/OpenClaw.Connection.Tests/IsolatedGatewayRuntimeTests.cs:1515, b762c8dc12a8)
  • History and related repairs: Feature history records isolated runtime work by Paul Campbell, Dallin Romney, Pedro Larroy, Karen, and Barbara Kudiess. The merged reconnect repair https://github.com/openclaw/openclaw-windows-node/pull/2276 (fix: Companion stops reconnecting after the native Gateway restarts) proves connection recovery after restart, not cron authority recovery. Historical blob inspection and blame encountered unavailable promisor objects, so line-level introduction remains unverified. (src/OpenClaw.Connection/NativeGateway/IsolatedGatewayRuntime.cs, b762c8dc12a8)
  • Canonical search did not establish supersession: Exact cron-authority search returned this issue and a synthetic UI fixture PR; body-reference search found no item referencing this issue. The inspected https://github.com/openclaw/openclaw-windows-node/issues/1903 concerns startup connection rejection rather than scheduler authority, consistent with the reporter distinguishing this outage from the chat hang.
How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge; those execution lanes are retired.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

Reviewed November 28, 2026, 11:25 PM ET / November 29, 2026, 04:25 UTC.

clawsweeper[bot] avatar Oct 28 '26 05:10 clawsweeper[bot]

@168062576-tech The outage is valid, but the repair owner is not yet established. Can the lock’s recorded starttime be compared with the actual start time and executable type of that PID, and can you identify the installed Gateway package version? Share only the comparison result and public package version, not the lock file or raw process dump. A live old Gateway and a recycled unrelated PID require different fixes. Keep this open; Companion should not delete authority locks or kill a process solely because it no longer owns the listening port.

roboclaw-bot avatar Nov 10 '26 19:11 roboclaw-bot

@roboclaw-bot Answering the two questions — comparison results only, no lock file content and no process dumps.

1) starttime comparison: the recorded owner was the live Gateway, and it is now dead

The lock's recorded PID no longer exists, so I compared the lock's recorded starttime against the timeline instead:

recorded pid 12792
recorded starttime 1794185851992 → 2026-11-09 00:57:31 UTC
lock createdAt 2026-11-09 01:01:35 UTC
createdAt − starttime +243 s (lock taken after the process had already started)
process with that pid today GONE — no such process

Conclusion: the recorded owner was the running Gateway process, not a recycled unrelated PID. Two independent signals support that:

  1. The lock was created 243 s after the recorded process started. The Gateway's own boot takes ~150 s before it reaches the cron phase, so a lock appearing ~4 min into a process's life is exactly the Gateway's own start-up sequence taking the authority. A recycled PID would instead show an arbitrary offset (the new process could have started at any time relative to the lock).
  2. The same signature appeared in my earlier reproduction on 2026-10-30: the Gateway's own runtime PID was 26692, while the lock recorded a different live node.exe PID (21100, started 12:52) that had taken the authority at 12:58 — again the same "process start → minutes later → lock" shape, i.e. a second, older Gateway instance that was still alive and holding the authority while the new Gateway could not take it.

So the failure mode is: a live older Gateway instance keeps the cron authority; the newer Gateway cannot take it and stays permanently UNAVAILABLE. After that instance eventually exits, the lock file is not reclaimed — which is the state it was in when I looked today (pid gone, lock still present).

2) Installed package versions

Component Version
Gateway MSIX package (OpenClawFoundation.OpenClawGateway) 2026.11.100.0 (core 2026.11.1)
Companion tray (OpenClaw.Tray.WinUI.exe) 2026.11.1.0

Recovery that worked on this machine

  1. Terminate the stale Gateway instance that owns the authority (it is a plain node.exe child of openclaw-session-host.exe, so it has to be stopped from the isolated session).
  2. Remove the stale lock file …/state/openclaw.sqlite.cron-authority.lock.
  3. Restart the Gateway — it then acquires the authority and cron starts ([cron] started, cron.status returns enabled: true).

I agree with the guidance that Companion must not delete authority locks or kill processes merely because they no longer own the listening port. The distinction that matters here is exactly the one you asked about: compare the lock's recorded starttime against the live PID's actual start time and executable identity — if they match, the owner is a still-running Gateway that must be asked to release the authority (or be stopped deliberately); if the PID is gone or its start time differs, the lock is stale and can be reclaimed safely.

One detail that may be useful for the fix: the lock record already carries both pid and starttime, and starttime is the process start time in epoch-ms. That is sufficient to distinguish a live owner from a recycled PID without needing any extra process dump.

3) Related context

This lock-ownership problem is separate from, but was observed alongside, the native-chat UI-thread hang tracked in #1568 / #1167 (InitialTailPositioner.StartTailRequest -> ItemsView.StartBringItemIntoView). The two can mask each other on the same machine: the cron outage shows up as "no automations run", while the UI hang shows up as "the app never responds". PR #1935 is open against the tail-positioning path.

For the record, on this machine both were present at the same time — the Gateway itself was healthy and serving health/tick traffic while the Companion UI thread was saturated on a single core, and separately the cron authority was held by an older Gateway instance that was still running.

168062576-tech avatar Nov 12 '26 08:11 168062576-tech

This issue has been automatically marked as stale due to inactivity. Please add updated OpenClaw Windows details or it will be closed.

github-actions[bot] avatar Nov 29 '26 03:11 github-actions[bot]