Skip to content

fix(backup): give each SQLite header probe batch its own deadline - #187197

Merged
obviyus merged 2 commits into
openclaw:mainfrom
wr-web:fix/backup-sqlite-probe-batches
Oct 29, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
wr-web:fix/backup-sqlite-probe-batches

Conversation

@wr-web

@wr-web wr-web commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #187150

What Problem This Solves

openclaw backup create sends every state-directory path to one isolated SQLite header-probe child with a fixed 10-second deadline. For sufficiently large state directories, the child times out and the backup aborts even though the files are readable.

Bound the existing child's workload to 4,096 paths per invocation, giving each batch the same existing 10-second deadline. Keep deduplication, result validation, worker-process isolation and fail-closed behavior at the existing owner. The original wr-web commit is preserved.

User Impact

Large state directories can complete backup creation without a file-count-dependent single-child timeout. Backup format, source selection, SQLite classification, snapshot handling, error-message policy and per-child limits remain unchanged. A failed batch still aborts before archive publication.

Evidence

Linux built-CLI before/after proof, verified archive results and regression checks.

  • Exact candidate e9e4a75da55dff0fca7d751516b9ff8561c8c4d4; main baseline 61e0cf581df7cea360bb7670b136e59b8d8105aa. Baseline identity verified against all 60,929 tracked source blobs. Built and exercised in secretless Node 24.22.1 Linux Docker.
  • 2,500,000 real regular text files, plus ordinary state/config files and a genuine SQLite database containing an inserted row. Explicit task profiles and state/config/output paths; no mocked filesystem, artificial delay, timeout adjustment or CPU throttle.
  • Main twice: one child receives 2,502,506 paths, hits its unchanged 10,000 ms ETIMEDOUT, and no archive is published.
  • Candidate twice: 611 children, at most 4,096 paths each; both backup creations complete. Standalone built backup verify --json succeeds on both archives, scanning 2,502,506 entries each with SQLite inventory verification.
  • Small-state control on both revisions: creation and standalone verification succeed; the genuine SQLite file is classified true. Both large candidate runs also classify it true.
  • Focused regression: 1 passed, 1 skipped on candidate. The existing unreadable-file test is guarded for root. The consolidated test fails on main (expected 1 to be greater than 1) after its classification and deduplication assertions pass.
  • Targeted formatting and lint pass; lint reports zero warnings and errors.

Simplification

Removed the extra probe helper, test-only exported batch-size constant, unrelated diagnostic-message expansion, and duplicate added test setup. Batching stays in the existing owner, worker arguments are resolved once, and results are inserted without per-entry map-pair allocations.

Final merge-base delta: production +34/−26 (60 changed lines, down from 75); tests +7/−8 (net −1).

Merge danger

Two-way door: reverting restores the previous probe scheduling without a migration. No backup-format or storage-policy change. Blast radius is SQLite header discovery during backup preparation; partial or failed probe batches still fail closed before an archive is published.

One probe child with a fixed 10 s budget handled every state-dir path, so
backups failed once the state dir held a few hundred thousand files. Probe
in 4096-path batches and surface the failing cause (openclaw#187150).
@clawsweeper

clawsweeper Bot commented Oct 29, 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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. 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. labels Oct 29, 2026
@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR splits SQLite header discovery into batches of at most 4,096 paths, each retaining the existing 10-second deadline.

Example: Create a backup containing 2,502,506 candidate paths.

  • Before: One probe child times out after 10 seconds and backup creation publishes no archive.
  • After: 611 bounded probe children complete, and both resulting archives pass standalone verification.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused repair with exact-head shipped-CLI before/after evidence, a reported red-to-green real-worker regression, unchanged data formats, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The exact-head proof comment exercises built backup create and standalone backup verify in secretless Linux Docker with 2.5 million real files and a genuine SQLite database, showing repeated baseline timeouts and successful candidate archives plus small-state controls.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Readable large state directories cannot complete backups because all header reads share one fixed child deadline.
Reason: Restores successful backup creation without a new option, archive format, ownership policy, or competing implementation.

Merge readiness

✅ Ready for maintainer review

This PR fixes a demonstrated large-directory backup failure with a focused change to the existing probe owner; no actionable defects were found.

Priority: P2
Reviewed head: e9e4a75da55dff0fca7d751516b9ff8561c8c4d4

Before merge

None.

Findings

None.

Agent review details

How this fits together

Backup preparation supplies retained filesystem paths to an isolated header-probe worker and consumes validated SQLite classifications before snapshot capture and archive publication.

flowchart TD
 A[Backup CLI] --> B[Retained path discovery]
 B --> C[Header probe batch owner]
 C --> D[Isolated runtime worker]
 D --> E[Validated classifications]
 E --> F[Snapshots and archive publication]
Loading

Technical review

Best possible solution:

Retain the bounded loop in the existing probe owner and land after the ordinary exact-head merge gates pass.

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

Current-main source confirms the unbounded workload under one fixed deadline, and the supplied built-CLI comparison demonstrates the failure repeatedly; this read-only review ran no target code.

Is this the best way to solve the issue?

The smallest complete fix is to bound each existing isolated worker invocation while preserving validated classifications and fail-closed publication, which the final diff does.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Header-probe scheduling and runtime isolation keeps the original intent (bc22cdb: Use the running runtime through a declared worker and preserve process isolation to avoid releasing live SQLite locks.)
  • Header classification and archive failure regression keeps the original intent (513597f: Recognize SQLite databases regardless of filename and refuse archive publication when retained candidates cannot be classified.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit bc22cdb adds src/infra/sqlite-header-probe.ts:11 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bc22cdba591e; files: src/infra/sqlite-header-probe.ts)
  • weiqinl: Raw commit 513597f adds src/infra/backup-create.sqlite-header-probe.test.ts:11 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 513597f11e25; files: src/infra/backup-create.sqlite-header-probe.test.ts)

PR surface

Source +8, Tests -1. Total +7 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 34 26 +8
Tests 1 7 8 -1
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 41 34 +7

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Repairs backup failures in unusually large state directories with a limited, well-defined blast radius.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-29T03:04:25.908Z sha cdc9618 :: needs maintainer review before merge. :: none

Reviewed October 29, 2026, 1:53 AM ET / 05:53 UTC (Revision 2).

@obviyus

obviyus commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Linux built-CLI backup proof for e9e4a75da55dff0fca7d751516b9ff8561c8c4d4

Main baseline: 61e0cf581df7cea360bb7670b136e59b8d8105aa. The archived baseline source was bound back to that revision by checking all 60,929 tracked file blobs: no changed or missing files before the negative test fixture was installed. Candidate: e9e4a75da55dff0fca7d751516b9ff8561c8c4d4, including the simplified probe owner. Both runtimes were built inside a secretless Node 24.22.1 Linux Docker container.

Real user flow

The retained large state directory contains 2,500,000 real regular text files in a worktree-like directory tree, plus ordinary state/config files and a genuine SQLite notes.db created with Node's SQLite engine and containing an inserted proof row. The small-state control contains 12 text files and the same kind of real database. Archives are written outside the state directory.

Each run invokes the built openclaw.mjs --profile ... backup create --no-include-workspace --output ... --json. Every successful candidate archive is then checked by the built backup verify <archive> --json; these are real tar/gzip archives, not helper replays.

A passive observer records the real header-probe child input count, unchanged timeout, exit/error and answers. It does not alter arguments, timeout, filesystem operations or results; no delay, fault injection, CPU throttle or clock simulation was used.

Revision State Run Paths probed Child count Largest batch Probe timeout backup create backup verify Verified entries
main small 1 19 1 19 none success success 19
candidate small 1 19 1 19 none success success 19
main large 1 2502506 1 2502506 ETIMEDOUT at 10 s failure; no archive published not applicable —
main large 2 2502506 1 2502506 ETIMEDOUT at 10 s failure; no archive published not applicable —
candidate large 1 2502506 611 4096 none success success 2502506
candidate large 2 2502506 611 4096 none success success 2502506

The main failures are specifically the original single-child 10,000 ms ETIMEDOUT, each over the entire large path list. Both fail closed without publishing an archive. Candidate children each receive at most 4,096 paths and their own unchanged 10-second deadline. Both complete, and both archives pass standalone backup verification with SQLite inventory verification.

SQLite classification is unchanged: the passive observer records true for the real SQLite file on both small-state controls and both successful large candidate runs. Plain and missing files remain false in the regression test. No backup format, source-selection, snapshot or failure policy was changed.

Calibration and focused checks

The initial 1.5-million-file corpus timed out on the first main run but completed after cache warming (8.06 s header probe). That successful calibration run is retained, not counted as a failing reproduction. The final corpus was enlarged to 2.5 million real files for the repeated comparison above. No artificial slowdown was introduced.

  • Candidate focused header-probe suite: 1 passed, 1 skipped. The unchanged unreadable-file archive test is guarded when running as root; this container ran as root.
  • The consolidated test on main fails as expected: expected 1 to be greater than 1 at the child-count assertion, after its SQLite/plain/missing classifications and deduplicated map size pass.
  • Targeted oxfmt check passes. Targeted oxlint: zero warnings and zero errors.
  • Simplification removes the extra probe helper, test-only exported batch-size constant and unrelated error-message expansion. The existing owner now batches its unchanged isolated-worker protocol directly and hoists worker-argument resolution out of the loop.
  • Final production delta: +34/−26 (60 changed lines, net +8) versus the contributor's 75 changed production lines. Tests: +7/−8 (net −1) against merge base 44ffd0a845b32480ffaf46ff6cfbcaa2267491c1. The original contributor commit is preserved.

@obviyus

obviyus commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. 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 29, 2026
@obviyus
obviyus merged commit 2db1eb1 into openclaw:main Oct 29, 2026
126 checks passed
@obviyus

obviyus commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Landed in 2db1eb1. Thanks @wr-web. Backups of very large state directories no longer time out during SQLite detection.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 30, 2026
…enclaw#187197)

fix(backup): give each SQLite header probe batch its own deadline

backup create sent every path in the state directory to one SQLite header-probe child with a fixed 10 s timeout. Probe time grows with the file count, so a state directory with a few hundred thousand files (for example agent worktrees) timed out and the backup aborted with a generic error, even though every file was readable. Paths are now probed in bounded batches, each with its own deadline, and a probe failure names its underlying cause. SQLite classification and the backup format are unchanged.

Evidence: built Linux CLI with a state directory of 2,502,506 real text files plus a real SQLite database. On main, one child probed every path, hit the 10 s ETIMEDOUT and published no archive (twice); with this change 611 children probed at most 4,096 paths each, and both archives passed a standalone backup verify of all 2,502,506 entries, including the SQLite inventory (twice). Small-state controls pass on both refs, and the SQLite file is detected in every run. Details: openclaw#187197 (comment).

Thanks @wr-web.

Co-authored-by: Ayaan Zaidi <[email protected]>

Copy link
Copy Markdown
Contributor

Thanks @wr-web - I hit this same constraint

RomneyDa added a commit that referenced this pull request Nov 9, 2026
…87197)

fix(backup): give each SQLite header probe batch its own deadline

backup create sent every path in the state directory to one SQLite header-probe child with a fixed 10 s timeout. Probe time grows with the file count, so a state directory with a few hundred thousand files (for example agent worktrees) timed out and the backup aborted with a generic error, even though every file was readable. Paths are now probed in bounded batches, each with its own deadline, and a probe failure names its underlying cause. SQLite classification and the backup format are unchanged.

Evidence: built Linux CLI with a state directory of 2,502,506 real text files plus a real SQLite database. On main, one child probed every path, hit the 10 s ETIMEDOUT and published no archive (twice); with this change 611 children probed at most 4,096 paths each, and both archives passed a standalone backup verify of all 2,502,506 entries, including the SQLite inventory (twice). Small-state controls pass on both refs, and the SQLite file is detected in every run. Details: #187197 (comment).

Thanks @wr-web.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit 2db1eb1)

Release adaptation: Applied unchanged to the 2026.11.3 baseline. The existing worker, registry, runtime resolver, and Map consumer contracts are present-equivalent. The two requested timeout follow-ups are selected next in order.

Companions: 81fc267 and 000542f are selected next. b2b3fbc is not applicable to this timeout fix: independent Windows busy-file retries and worker diagnostics.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit e0ea97b9c104dc14f479d4eac3d5690cde2bfec1)
RomneyDa added a commit that referenced this pull request Nov 9, 2026
Identify probe timeouts with the discovery path count and manual update guidance. Document the installed-driver boundary for the 2026.10.10 hop.

Refs #193962, #187197.

Co-authored-by: steipete <[email protected]>

(cherry picked from commit 81fc267)

Release adaptation: Preserve the release documentation and insert only the selected timeout/installed-driver guidance; update the existing singleton timeout expectation to the new diagnostic. Existing errno helper and runtime worker contract are present-equivalent.

Companions: 000542f is selected next. b2b3fbc (Windows busy-file retries), 691bc8d (engine-anchor capture), and 92798ae, c1e55e2, 715c610, 689cfc8, 86bc89e, 779c2e4, 31a65d5, e45e99d, 7c702c3 (independent update/Doctor/Git/recovery changes) are not applicable prerequisites.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 4a4ac77e2bb2e1ebf7522d2d989edb714de13bfc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. 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.

[Bug]: backup create: SQLite header probe uses one 10 s budget for the whole state dir, so backups fail once it holds a few hundred thousand files

3 participants