Skip to content

fix(update): allow SQLite readers during stopped database backups - #180827

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-update-snapshot-shm-change-20260919
Oct 22, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-update-snapshot-shm-change-20260919

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Update/Doctor's stopped database backup can abort when a read-only SQLite probe opens the WAL database during capture. SQLite readers update or recreate the transient -shm WAL index, which was incorrectly treated as durable source data.

User Impact

Read-only probes no longer block the stopped backup. Main database, nonempty WAL, and rollback-journal changes still fail closed; an empty WAL created by a reader counts as absent. No schema, configuration, or backup-format change.

Why This Change Was Made

Exclude -shm from the stopped backup inventory and from the private copy's journal-presence comparison. The existing snapshot owner already copies and verifies the main database plus committed WAL frames, rebuilds its private index, and publishes a verified standalone database. Keep that owner instead of opening another source connection that could affect POSIX lock lifetime or source cleanup. Journal appearance/disappearance errors now name the changed file too.

Production change: net +2 lines. Removed the redundant sidecar comparator; the necessary growth handles a real reader creating an empty WAL and identifies changed journal files. No extra snapshot path or cache. Simplification pass completed.

Evidence

Acceptance: a real independent SQLite reader during stopped capture must succeed without changing source main/WAL bytes; the published snapshot must restore byte-identically and retain both committed rows, including the uncheckpointed WAL row. Real independent writers must still fail closed.

  • Baseline: an existing-index reader fails with Update database file changed during backup: ...-shm; a reader creating the index fails with Update database journal state changed during stopped backup.
  • Baseline: reader-created index during private copying causes 2 main-file copies. Candidate requires 1, with unchanged main/WAL bytes and the retained WAL row. This is a deterministic work count, not a latency benchmark.
  • A third real Node reader case creates an empty WAL beside a checkpointed database. It fails before empty-WAL normalization and passes after it.
  • Independent Node writer and checkpoint-writer controls fail closed with the changed database path.
  • Final changed-file run: 60/60 passed across update-database-backup.test.ts and sqlite-readonly-location.copy.test.ts (66.82 s command wall time; backup test bodies 39.307 s, copy test bodies 1.421 s). The backup file exercises worker-backed original-state recovery contracts as well as the new sub-second reader/writer cases. The unchanged sibling sqlite-readonly-location.test.ts also passed 25 tests with one platform skip.
  • Changed-file formatting and lint passed. Targeted tsgo:core (tsrs) passed before the final empty-WAL addition; exact-head broad checks are delegated to PR CI.
  • Fresh independent Codex review of the final patch: clean through P2. No production or remote benchmark host was accessed.

Limitations: no production access or load testing; no full installed-package upgrade campaign. The candidate-worker backup boundary and real SQLite subprocesses are exercised locally. The fix must be in the runtime performing capture. A completed external write has no reliable PID attribution in filesystem metadata, so errors identify the file rather than accusing an unrelated open-file holder.

Ignore the transient WAL index and reader-created empty WAL files when fencing a stopped backup. Retain main, nonempty WAL, and rollback-journal change detection, with named journal diagnostics. Reuse coherent private snapshot capture and cover independent SQLite readers, writers, restored bytes, and committed WAL rows.
@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

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

chatgpt-codex-connector Bot commented Oct 22, 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-22T17:31:39.581591Z aaec974 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 size: S labels Oct 22, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 22, 2026
@clawsweeper

clawsweeper Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The PR allows SQLite readers during stopped database backups while retaining detection of durable database changes.

Example: A read-only SQLite probe recreates openclaw.sqlite-shm while a stopped backup captures two committed rows.

  • Before: Capture aborts because the transient WAL index changed.
  • After: Capture succeeds with both rows preserved; independent database writes still cause refusal.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with meaningful real-SQLite boundary coverage; supplied proof stops short of a shipped update entry point.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied evidence covers the backup owner with real SQLite readers and writers, while full installed-upgrade behavior remains unclaimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Update or Doctor can abort a stopped database backup when an independent read-only SQLite probe changes transient WAL bookkeeping.
Reason: The maintainer-authored direction restores reader tolerance without changing configuration, backup formats, or durable-write rejection.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it fixes a current stopped-backup failure with a focused change, and no concrete introduced defect was found.

Priority: P2
Reviewed head: aaec9745cfae6b9786aff5c80f98a5979206eaa5

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: A full installed-package published-driver-to-candidate upgrade is not demonstrated; supplied validation exercises the production backup owner with real SQLite subprocesses.
Agent review details

How this fits together

Update and Doctor send discovered SQLite database families to the backup owner, which publishes verified standalone snapshots and recovery metadata.

flowchart LR
  A[Update or Doctor] --> B[Database backup owner]
  C[SQLite database family] --> B
  D[Independent SQLite reader] --> C
  B --> E[Private snapshot owner]
  E --> F[Verified recovery image]
Loading

Technical review

Best possible solution:

Retain the existing snapshot owner and distinguish transient reader bookkeeping from durable database changes.

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

Current-main source treats reader-mutated SHM as backup state, and the supplied baseline results identify the corresponding failures; this review ran no target code.

Is this the best way to solve the issue?

The patch repairs both existing comparison owners, preserves durable-file checks, and introduces no competing snapshot path.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit ec7f8e9 adds src/infra/sqlite-readonly-location.ts:205 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ec7f8e9dd1c3; files: src/infra/sqlite-readonly-location.ts)

PR surface

Source +2, Tests +128, Docs +8. Total +138 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 16 14 +2
Tests 2 145 17 +128
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 169 31 +138

Review metrics

Metric Value Why it matters
Production versus test LOC Production +16/-14; tests +145/-17 The small production change reuses existing owners; test growth covers distinct reader states, writer rejection, restored bytes, and avoided duplicate copying.

Labels

Label changes:

  • add P2: Concurrent read-only probes can abort stopped Update or Doctor capture, but the demonstrated failure refuses the backup rather than corrupting data.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Concurrent read-only probes can abort stopped Update or Doctor capture, but the demonstrated failure refuses the backup rather than corrupting data.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 22, 2026, 1:43 PM ET / 17:43 UTC.

@steipete
steipete merged commit 082e55e into main Oct 22, 2026
223 of 227 checks passed
@steipete
steipete deleted the steipete/perf-micro-update-snapshot-shm-change-20260919 branch October 22, 2026 17:50
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 23, 2026
…enclaw#180827)

Ignore the transient WAL index and reader-created empty WAL files when fencing a stopped backup. Retain main, nonempty WAL, and rollback-journal change detection, with named journal diagnostics. Reuse coherent private snapshot capture and cover independent SQLite readers, writers, restored bytes, and committed WAL rows.
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
…80827)

Ignore the transient WAL index and reader-created empty WAL files when fencing a stopped backup. Retain main, nonempty WAL, and rollback-journal change detection, with named journal diagnostics. Reuse coherent private snapshot capture and cover independent SQLite readers, writers, restored bytes, and committed WAL rows.

Release adaptation: stable has no stopped-backup journal-set comparison, so only the -shm exclusion, empty-WAL normalization (number Stats size on stable), and the private-copy sidecar comparison apply. Stable's capture is online, so the ported regression keeps reader cases, adds recreated -shm/empty-WAL inode cases that fail without the fix, and accepts stable's existing writer outcome (changed-generation warning or identity refusal).

(cherry picked from commit 082e55e)
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
…80827)

Ignore the transient WAL index and reader-created empty WAL files when fencing a stopped backup. Retain main, nonempty WAL, and rollback-journal change detection, with named journal diagnostics. Reuse coherent private snapshot capture and cover independent SQLite readers, writers, restored bytes, and committed WAL rows.

(cherry picked from commit 082e55e)

Adapted for 2026.9.x: ported only the sqlite-readonly-location.ts sidecar check, so a reader-created -shm no longer forces a read-only copy retry. The update-database-backup.ts hunks are not ported: 9.x has no stopped-backup journal key-set comparison and its final inventory check compares dev/inode identity only, so -shm content changes and reader-created empty WAL files do not abort 9.x backups. The docs paragraph describes that main-only stopped-backup behavior and is omitted. The regression is a 9.x-native sync copy test that counts main-database opens with and without a mid-copy -shm creation.
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 P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant