Skip to content

fix(sqlite): snapshot live databases through the online-backup owner - #175774

Merged
steipete merged 1 commit into
mainfrom
upd/upd-l1676
Oct 17, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/upd-l1676

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Fixes #160483

What Problem This Solves

config validate and plugin-update config/inventory reads can exhaust ten private SQLite copy attempts while a live Gateway checkpoints its WAL, even though the database is healthy.

User Impact

CLI plugin metadata inspection can read a busy live database without waiting for its files to stop changing. Offline, unverifiable-owner, inherited-snapshot, and schema-maintenance reads retain artifact-preserving behavior. Snapshot errors still fail with their existing diagnostics; unreadable inventory is never treated as empty.

Why This Change Was Made

The shared snapshot worker now checks the exact database's recorded Gateway or embedded-writer owner using the existing process-identity verifier. A verified live owner selects the existing online-backup implementation, which pins one read transaction and permits normal SHM read marks. Other sources retain private copying. Physical identity, admission, and cleanup checks remain in place.

Removed the separate metadata snapshot operation and its extra dispatch; metadata now uses the shared snapshot lifecycle. Native backup runs in a one-shot child, retaining the existing protection against persistent-IPC backup stalls. No schema, stored-data, or user-config changes.

Evidence

  • Regression: concurrent checkpointing of a 32 MiB WAL database exhausts all 10 raw-copy attempts. Live-owner acquisition then succeeds, passes integrity_check, preserves equal transaction generations, and keeps the retained snapshot below 34 MiB.
  • Absent and unverifiable owners remain byte-neutral; a replaced source identity is rejected. Config metadata and the write snapshot used by plugin updates both validate while a recorded live owner checkpoints the database, without main-thread SQL.
  • Isolated, fully ready Gateway on the committed tree: pnpm openclaw config validate --json returned valid:true, warnings:[]; pnpm openclaw plugins update --all --dry-run exited 0 with no tracked installs. Gateway stayed alive through both commands and logged clean shutdown in 131 ms. This was an inventory/preflight smoke, not a package installation. The earlier dirty-tree source launch hit the artifact-publication fence before SQLite; committing the reviewed inputs resolved that launcher-only refusal.
  • Focused tests passed: metadata ownership regression, config snapshots, plugin metadata, worker diagnostics, and retained-child compile-cache cleanup. Core and focused test type checks, touched-file oxlint/oxfmt, import-cycle check, line-cap and SQLite worker ratchets passed. Independent Codex review: no actionable P0–P2 findings. Repaired packaging proof: 82 tests passed across the service-relay, wrapper-closure, and state-worker build suites.
  • All 77 selected sibling/focused files passed across the recorded runs. The final 55-file sweep passed 623 tests with five pre-existing skips in 782.66 s; the earlier 11-file unit lane passed 86 tests, all 8 tooling files passed after the packaging fix, and the final focused run passed 101 tests. The final sweep retained original file order in its invocation and used one worker. The unchanged test/scripts/vitest-worker-artifacts.test.ts took 185.869 s (30 tests); its slowest case, “builds changed source despite valid stale dist and fails visibly on build errors,” took 38.456 s because it builds full worker graphs and reconstructs the fixture checkout. No timeouts or retries were raised.
  • Full check:changed SQLite inventory was omitted under the local gate budget. The max-lines checker reports inherited suppressions in untouched chat-message.test.tsx, config-page-state.ts, and sessions-page-state.ts; these files match the starting HEAD.

Production: +92/-188 (net -96). Tests: +250/-8 (net +242). Documentation: +8/-0. Wrapper inventory: -1 obsolete entry.

Focused and live proof commands

All runtime commands used isolated HOME and OPENCLAW_STATE_DIR beneath the worktree’s .artifacts/l1676/; no existing Gateway was used or stopped.

node scripts/run-vitest.mjs test/scripts/eager-import-closure.test.ts test/scripts/tsdown-config.test.ts test/scripts/pr-wrapper-source-closure.test.ts test/scripts/state-read-worker-build.test.ts src/infra/sqlite-readonly-location.metadata.test.ts src/config/io.load-async.test.ts --maxWorkers=1
# 101 tests passed across the 6 selected files.

pnpm openclaw gateway run --port 56767
# Waited for /readyz: HTTP 200.
pnpm openclaw config validate --json
# Exit 0: valid=true, warnings=[].
pnpm openclaw plugins update --all --dry-run
# Exit 0: No tracked plugins or hook packs to update.
# The task-owned Gateway remained running, then joined its SIGTERM shutdown.

@clawsweeper

clawsweeper Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review October 17, 2026 18:46
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T18:49:51.031917Z 604fde1 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: L labels Oct 17, 2026
@steipete
steipete merged commit f150189 into main Oct 17, 2026
223 of 228 checks passed
@steipete
steipete deleted the upd/upd-l1676 branch October 17, 2026 18:58
steipete added a commit that referenced this pull request Oct 17, 2026
Replace the infra/integration name split with the existing weighted
allocator over the unchanged target inventory. Commit advisory target
weights; new tests still enter the inventory with a default weight.
Keep worker limits and the existing aggregate gate. Count all three
hosted jobs in admission and restore a 30-minute deadline for every row.

Three hourly runs measured 23.28/12.70, 26.22/15.75, and 25.80/24.87
minutes (35.98, 41.97, and 50.67 total job-minutes). Replaying per-file
spans, project overhead, and the single runtime-build owner projects:
10.82/11.58/17.57, 12.85/13.98/18.30, and 16.43/18.70/20.16 minutes.
For the latest workload, the critical path drops about 5.6 minutes (22%)
at a cost of about 4.6 extra job-minutes. The slowest row has 9.84 minutes
of deadline margin. These are projections, not post-change CI results;
the latest infra run includes eight failed cases and already has #175774.

Evidence: all 88 targets occur exactly once in the dry-run partition.
The old runner fails the new numeric-shard regression. Focused runner,
workflow, admission and allocator tests pass (41 selected tests), as do
targeted types, script/test lint, format, syntax and workflow validation
with pinned actionlint and zizmor. Final P2 review is scoped-clean.
No CI dispatches or reruns were used for proof.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
…penclaw#175774)

Read-only state snapshots used for config and plugin metadata (openclaw config validate, plugin update ownership/inventory) copied the database files and compared them until they stopped changing; against a busy live Gateway, WAL/checkpoint churn exhausted all ten attempts and the command failed. When the database's recorded owner is verified live (pid + start time + namespace), metadata reads now take one transactionally consistent snapshot through the existing online-backup owner. Offline, forensic, recovery and unverifiable-owner reads keep the byte-neutral copy path and existing guards. The integrity-and-recovery contract documents the split.

Fixes openclaw#160483
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
Replace the infra/integration name split with the existing weighted
allocator over the unchanged target inventory. Commit advisory target
weights; new tests still enter the inventory with a default weight.
Keep worker limits and the existing aggregate gate. Count all three
hosted jobs in admission and restore a 30-minute deadline for every row.

Three hourly runs measured 23.28/12.70, 26.22/15.75, and 25.80/24.87
minutes (35.98, 41.97, and 50.67 total job-minutes). Replaying per-file
spans, project overhead, and the single runtime-build owner projects:
10.82/11.58/17.57, 12.85/13.98/18.30, and 16.43/18.70/20.16 minutes.
For the latest workload, the critical path drops about 5.6 minutes (22%)
at a cost of about 4.6 extra job-minutes. The slowest row has 9.84 minutes
of deadline margin. These are projections, not post-change CI results;
the latest infra run includes eight failed cases and already has openclaw#175774.

Evidence: all 88 targets occur exactly once in the dry-run partition.
The old runner fails the new numeric-shard regression. Focused runner,
workflow, admission and allocator tests pass (41 selected tests), as do
targeted types, script/test lint, format, syntax and workflow validation
with pinned actionlint and zizmor. Final P2 review is scoped-clean.
No CI dispatches or reruns were used for proof.
RomneyDa added a commit that referenced this pull request Oct 28, 2026
Replace the infra/integration name split with the existing weighted
allocator over the unchanged target inventory. Commit advisory target
weights; new tests still enter the inventory with a default weight.
Keep worker limits and the existing aggregate gate. Count all three
hosted jobs in admission and restore a 30-minute deadline for every row.

Three hourly runs measured 23.28/12.70, 26.22/15.75, and 25.80/24.87
minutes (35.98, 41.97, and 50.67 total job-minutes). Replaying per-file
spans, project overhead, and the single runtime-build owner projects:
10.82/11.58/17.57, 12.85/13.98/18.30, and 16.43/18.70/20.16 minutes.
For the latest workload, the critical path drops about 5.6 minutes (22%)
at a cost of about 4.6 extra job-minutes. The slowest row has 9.84 minutes
of deadline margin. These are projections, not post-change CI results;
the latest infra run includes eight failed cases and already has #175774.

Evidence: all 88 targets occur exactly once in the dry-run partition.
The old runner fails the new numeric-shard regression. Focused runner,
workflow, admission and allocator tests pass (41 selected tests), as do
targeted types, script/test lint, format, syntax and workflow validation
with pinned actionlint and zizmor. Final P2 review is scoped-clean.
No CI dispatches or reruns were used for proof.

Adapted for beta.5 numeric shard API compatibility only. Upstream evidence above describes the donor, not local release qualification.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation scripts Repository scripts size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin update stalls, then fails when live SQLite state cannot stabilize for read-only snapshot (2026.9.6)

1 participant