Repository navigation
fix(state): healthy Gateway starts log SQLite lock-wait warnings for retried lease work - #167754
Conversation
Let lease owners handle expected nonblocking BEGIN failures while preserving ordinary contention and commit diagnostics. Share native and worker lease write policy, including existing-schema writers, without changing retry or authority semantics.
|
🦞👀 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. |
|
Codex review: needs maintainer review before merge. What this changesThe PR stops misleading SQLite lock-wait warnings for nonblocking lease renewal and release attempts whose contention is already handled by the lease owner. Example: An operator starts the Gateway while plugin lifecycle lease work encounters database contention.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR remains useful: current main retains the misleading diagnostics, the area owner accepted the narrow correction, and no actionable patch defect was found. Priority: P3 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe shared SQLite database stores temporary leases that coordinate Gateway work. Lease owners acquire, renew, and release them through database transactions with existing retry, expiry, and authority checks. flowchart TD
A[Gateway lifecycle work] --> B[Lease owner]
B --> C[Shared lease writer]
C --> D[SQLite transaction]
D --> E{Failure phase}
E -->|Nonblocking lease BEGIN| F[Return error without transaction warning]
E -->|Ordinary BEGIN or COMMIT| G[Preserve transaction warning]
F --> B
Technical reviewBest possible solution: Keep diagnostic policy in the shared lease writer while preserving the existing transaction, retry, expiry, and authority owners. Do we have a high-confidence way to reproduce the issue? Yes: zero-timeout lease BEGIN contention reaches generic failure reporting before the lease owner handles it. Source supports the reported Gateway observations and base-failing regressions; this review did not execute them. Is this the best way to solve the issue? Yes: the shared lease-write boundary selects the narrow reporting policy, preserving error propagation, acquisition waits, COMMIT diagnostics, and authority checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9490c112abba. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +8, Tests +131, Docs +4. Total +143 across 7 files. Added test files: 1. View PR surface stats
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 HistoryReviewed October 9, 2026, 6:03 AM ET / 10:03 UTC (Revision 3). |
Merge cff1f4f to fix the named checks-fast-baseline-ratchets failure from CI run 37911652063. The failure was inherited from the main merge base: src/config/sessions/session-accessor.sqlite-read.ts had 2 assertions against an allowance of 3. The assertion safety ratchet now passes. The reviewed lease diagnostics delta is unchanged.
|
@clawsweeper approve Maintainer decision (coordinator for Peter, 2026-10-09): diagnostics-only fix - expected, already-retried lease try-lock contention is not reported as a lock-wait failure; no lease, schema, or durability semantics change. |
|
🦞👀 Command router queued. I will update this comment with the next step. |
CI run 37912360699 failed check-test-types-core-1 on the inherited zero-argument SIGINT listener call in src/cli/update-cli.windows-lifecycle.test.ts. Main repaired that call in 3223e13. The same error reproduces on the older main tooling checkout; the focused CLI update typecheck passes after this merge. Lease diagnostics patch ID is unchanged.
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
Let lease owners handle expected nonblocking BEGIN failures while preserving ordinary contention and commit diagnostics. Share native and worker lease write policy, including existing-schema writers, without changing retry or authority semantics.
What Problem This Solves
Fixes: almost every Gateway start logs a SQLite "lock wait failed" warning for shared-state lease work that is already retried, so operators see lock-contention warnings on healthy starts:
On a dev Gateway with lived-in state this appeared 13 times over 16 starts.
User Impact
Healthy starts no longer log lock-contention warnings for lease renewal/release attempts that the lease owner already retries or lets expire. Ordinary transaction contention and COMMIT failures still report as before; lease errors, authority checks, retry budgets, and persistence are unchanged.
Why This Change Was Made
Both lease callers acquire through workers with a 5 s busy timeout; their zero-timeout paths are renewal and release, whose BEGIN contention is handled by the existing lease retry and expiry logic. The generic BEGIN reporting in
src/infra/sqlite-transaction.tsstill logged those expected try-lock failures. The lease write owner (src/state/openclaw-state-lease-storage.ts) now marks its BEGIN contention as handled across the native, existing-schema, and worker writer paths, and duplicate worker wrappers were removed. Production +66/−58.Shutdown
WAL checkpoint TRUNCATE remained busy(also seen on many clean shutdowns) was investigated but is not changed here: the logs cannot attribute the blocker, and shutdown checkpoint ordering falls under the storage approval checkpoint.Evidence
pnpm test src/state/openclaw-state-lease-diagnostics.test.ts --maxWorkers=1: 3 failed / 1 passed with the original production code (the unwanted warning assertions), 4 passed with the fix (20 s wall).Landing validation
checks-fast-baseline-ratchetson an inherited stale assertion allowance:src/config/sessions/session-accessor.sqlite-read.ts: 2 < 3. Main fixed that exact allowance in cff1f4f. Merged main for that named failing gate, producing a30bd35; the PR delta has the same stable patch ID.pnpm check:assertion-safety --base origin/mainpasses after the merge. No workflow rerun was requested.check-test-types-core-1on an inherited Windows lifecycle fixture (src/cli/update-cli.windows-lifecycle.test.ts:545, TS2554: listener called without its signal). The error also reproduced on the older main checkout. Main fixed it in 3223e13; merging that named gate fix produced a013a01. The focusednode scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.cli-update.json --noEmitcheck passes after the merge, and the lease fix retains the same patch ID.Inherited CI exception
CI run 37913649528, attempt 1, failed
checks-node-changed-compact-large-15(job 113764943537) inserver-close.memory.test.ts, case “joins accepted Memory sync through Gateway close without reopening its executor between publications”:memory-core dreaming SQLite state store is not configured. The identical error reproduces on main b92562c without this PR (1 failed, 2 skipped; 44.46 s). The test, its fixture, and the reported failure-path sources are unchanged between that main snapshot, tested baseline 3223e13, and this PR. The runtime-store lookup fails before Memory workspace lock acquisition, independently of the lease BEGIN diagnostic change.The failed CI checkout is d6eef5bac41b3ac78a863b40d9815b6e46ca1153, with ordered parents 3223e13 and a013a01. The aggregate gate names that single root failure; the successful fail-fast monitor cancelled five sibling jobs. Those cancellations remain incomplete coverage, not passing checks. Security-fast and the scoped lease proof passed. Landing uses the explicitly authorized native pre-existing-failure exception; no unrelated Memory fix or workflow rerun is included.