Repository navigation
fix(update): Bun-run updates fail with database is locked before replacing the package - #170519
Conversation
|
🦞👀 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 changesThis PR releases completed SQLite snapshot locks so Bun update admission and later writer commits can proceed. Example: Run openclaw update under Bun 1.4.2 with an existing managed-update-handoffs.sqlite database.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it repairs a current shared SQLite lock-release defect, and no introduced correctness or security bug was found; the required CI gate remains failed. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe existing-database helper provides identity-bound rollback-journal snapshots and writer transactions to update handoff, activation, and recovery owners. flowchart TD
A[Update command] --> B[Executor lease owner]
B --> C[Handoff database owner]
D[Activation and recovery owners] --> E[Existing SQLite helper]
C --> E
E --> F[Read snapshot]
F --> G[Release snapshot lock]
G --> H[Guarded writer commit]
Technical reviewBest possible solution: Keep the repair in the shared snapshot owner while preserving journal admission, physical identity checks, and existing writer authority. Do we have a high-confidence way to reproduce the issue? Current main retains the implicated release sequence, and the independent-writer and Bun executor fixtures target it directly; the author reports baseline failures, while this read-only review executed no target code. Is this the best way to solve the issue? The patch repairs native lock settlement at the existing shared owner without retries, journal-mode changes, or another ownership mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b36ed3195cb4. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +7, Tests +128, Config +3, Other +1. Total +139 across 8 files. Added test files: 3. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 (1 earlier review cycle)
Reviewed October 12, 2026, 10:12 PM ET / October 13, 2026, 02:12 UTC (Revision 2). |
6d1970c to
721b4e9
Compare
#170519's Bun existing-store regression launches this source helper by path. Register that exact execution entry in the full-tree Knip audit so its live update-executor regression is retained without an ignore. The unchanged opt-in Bun regression and deadcode checker tests pass. No runtime, update behavior, assertions or timeouts change.
* fix(test): expose lazy report capture to export analysis The Vitest 5 migration loads its report-capture constructor through a CLI file path, which the script export scan cannot resolve. Register that existing reporter path with a literal lazy import in the redacting loader, preserving the constructor, options and forwarding lifecycle. No Knip ignore, eager loading, test suppression or user-visible change. The original Solid leftovers are covered by #170660; #170680 owns the separate permission-card export repair. * test(tooling): register Bun SQLite regression fixture #170519's Bun existing-store regression launches this source helper by path. Register that exact execution entry in the full-tree Knip audit so its live update-executor regression is retained without an ignore. The unchanged opt-in Bun regression and deadcode checker tests pass. No runtime, update behavior, assertions or timeouts change.
## What Problem This Solves Scheduled main CI reports `src/infra/sqlite-existing-database.bun.test-support.ts` as unused. The helper is live: the Bun regression added by #170519 launches it through a plain path string that Knip cannot connect to the test. Resolve the actual subprocess argument with `fileURLToPath(new URL(..., import.meta.url))`, following the existing fixture pattern. This makes the dependency visible while preserving the Bun helper, every assertion, the isolated environment, and the existing timeout. No ignore entries or production changes are added. ## Evidence - Original failure: [scheduled run 38359584345, check-dependencies](https://github.com/openclaw/openclaw/actions/runs/38359584345/job/115170478488). The full-tree unused-file scan reports this one helper; production-file and all unused-export scans passed. - Culprit: `5dbb5799d2e747d5630f966a72cc576a0049bd83` (#170519), verified against its parent. Launcher and helper blobs on base `cdd0d2df564828ecf9fa01c03ae655af8c952b06` match the failing scheduled head. - Changed-file oxfmt, oxlint, and `git diff --check` passed. - One independent Codex review completed scoped-clean at P0–P2. - The exact full-tree unused-file scan passed on candidate `d79c87980ff41b2218803b907201de9cfa164ff6`: [run 38363318115, job 115182433252](https://github.com/openclaw/openclaw/actions/runs/38363318115/job/115182433252), Knip 6.32.2, unchanged configuration and `--files` arguments, zero diagnostics in 130.2 seconds. Source-preservation verification passed. Ordinary PR CI 38362413570 passed all selected static, type, architecture, security, and required gates. T1 remained 454 to 454, compatibility calls 9 to 9, and dialect groups 0 to 0. No local Knip, typecheck, or runtime test was run under the compute-conservation rule. - Test LOC: +2/-1; production LOC: 0. No SQL or runtime behavior change.
…files Squashed onto current main; keeps #170519's Bun launcher checks alongside the retained-import preload checks.
…acing the package (openclaw#170519) * fix(update): release the existing-store snapshot lock so Bun updaters can commit * fix(update): keep the snapshot lock release within the existing pragma budget
…70701) * fix(test): expose lazy report capture to export analysis The Vitest 5 migration loads its report-capture constructor through a CLI file path, which the script export scan cannot resolve. Register that existing reporter path with a literal lazy import in the redacting loader, preserving the constructor, options and forwarding lifecycle. No Knip ignore, eager loading, test suppression or user-visible change. The original Solid leftovers are covered by openclaw#170660; openclaw#170680 owns the separate permission-card export repair. * test(tooling): register Bun SQLite regression fixture openclaw#170519's Bun existing-store regression launches this source helper by path. Register that exact execution entry in the full-tree Knip audit so its live update-executor regression is retained without an ignore. The unchanged opt-in Bun regression and deadcode checker tests pass. No runtime, update behavior, assertions or timeouts change.
) ## What Problem This Solves Scheduled main CI reports `src/infra/sqlite-existing-database.bun.test-support.ts` as unused. The helper is live: the Bun regression added by openclaw#170519 launches it through a plain path string that Knip cannot connect to the test. Resolve the actual subprocess argument with `fileURLToPath(new URL(..., import.meta.url))`, following the existing fixture pattern. This makes the dependency visible while preserving the Bun helper, every assertion, the isolated environment, and the existing timeout. No ignore entries or production changes are added. ## Evidence - Original failure: [scheduled run 38359584345, check-dependencies](https://github.com/openclaw/openclaw/actions/runs/38359584345/job/115170478488). The full-tree unused-file scan reports this one helper; production-file and all unused-export scans passed. - Culprit: `d07e31eb2f581fd4147186fbed2045a6dc8f0faf` (openclaw#170519), verified against its parent. Launcher and helper blobs on base `1f32c05dc71dcd8a08761edc3410f6ecad85278b` match the failing scheduled head. - Changed-file oxfmt, oxlint, and `git diff --check` passed. - One independent Codex review completed scoped-clean at P0–P2. - The exact full-tree unused-file scan passed on candidate `d79c87980ff41b2218803b907201de9cfa164ff6`: [run 38363318115, job 115182433252](https://github.com/openclaw/openclaw/actions/runs/38363318115/job/115182433252), Knip 6.32.2, unchanged configuration and `--files` arguments, zero diagnostics in 130.2 seconds. Source-preservation verification passed. Ordinary PR CI 38362413570 passed all selected static, type, architecture, security, and required gates. T1 remained 454 to 454, compatibility calls 9 to 9, and dialect groups 0 to 0. No local Knip, typecheck, or runtime test was run under the compute-conservation rule. - Test LOC: +2/-1; production LOC: 0. No SQL or runtime behavior change.
What Problem This Solves
Fixes:
openclaw updaterun under Bun fails before replacing the package withdatabase is lockedonmanaged-update-handoffs.sqlite.User Impact
Bun-run updates get past executor admission and handoff lease writes instead of failing every time after a 5 s wait. Update behavior is otherwise unchanged. Node updaters were not affected and behave the same.
Why This Change Was Made
The existing-store helper (
withExistingSqliteRollbackDatabase) takes its read snapshot withPRAGMA locking_mode = EXCLUSIVEso a foreign WAL store is refused without creating sidecars, then switches back toNORMAL. SQLite appliesNORMALonly at the next file access, soROLLBACKalone kept the snapshot's SHARED lock until the connection closed. Node closes immediately; Bun'sclose_v2defers closing while prepared statements remain, so the update executor's own writer could never commit and timed out withSQLITE_BUSY.After ending the snapshot, the helper now performs one autocommit
PRAGMA schema_versionread, which makes SQLite drop the retained lock. It runs only after the store was verified to use a rollback journal, so it cannot create WAL sidecars. The same fix stops a retained reader from holding the lock between observations on Node too.Update behavior: the installed updater runs first, so this takes effect for updates run by an updater that ships this change. No schema, durability, retention, or lease/authority semantics change.
Evidence
withUpdateCommandExecutoradmission failed after 4.9 s atstep=commitwithdatabase is locked; the same driver passes under Node (83 ms) and, with the fix, under Bun (56 ms). Isolated A/B: the existing-store write path failed twice under Bun onmainand passes with the fix.openclaw updatein Docker (Linux, packed build of this branch → version-bumped target, isolated state,--no-restart):src/infra/sqlite-existing-database.test.ts(Node): a retained reader releases its snapshot lock while its connection stays open. Fails onmainwithdatabase is locked, passes here.pnpm test <file> --maxWorkers=1: 2.2 s wall, ~10 ms test.src/infra/sqlite-existing-database.bun.test.ts: runs the existing-store writes and the real update executor admission under Bun. Fails onmainwithdatabase is locked, passes here (~1.1 s). Wired into the existingchecks-fast-bun-launchertask; changes tosrc/infra/sqlite-existing-database.*now select it.pnpm tsgo:core,tsgo:scripts,tsgo:core:test,tsgo:test:root, oxlint and oxfmt pass. Autoreview: clean.Separate pre-existing Bun failure (not fixed here)
With the lock fixed, a Bun-run update fails at
candidate-plugins(plugins list --json) withRuntime config source changed during asynchronous preparation. Cause: in Bun 1.4.2, creating the firstworker_threadsWorker withenv: SHARE_ENVreplaces theprocess.envobject, and the old object is detached (writes no longer reach the new one).captureRuntimeConfigAsyncReadercorrectly notices that identity change. Node keepsprocess.envstable. That fix belongs to the worker/runtime-env owner and is left for its own change.