Skip to content

fix(backup): allow backups while the gateway is running - #119782

Merged
vincentkoc merged 1 commit into
mainfrom
fix/backup-transient-lock-sqlite
Aug 6, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/backup-transient-lock-sqlite

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 6, 2026 •

Copy link
Copy Markdown
Member

Fixes #119757

Reported by @AgentSolomon in #119757.

What Problem This Solves

Fixes an issue where operators running openclaw backup create --verify while the gateway was active could not create a backup because the gateway's disposable SQLite coordination database remained locked.

Why This Change Was Made

The backup volatile-file boundary now owns one canonical SQLite transient classifier. It excludes exact gateway and device coordinator database names only inside the authoritative CLI and managed-service lock directories, while retaining durable SQLite databases with similar names elsewhere. Reindex scratch databases remain excluded across discovery, archive creation, and verification.

No config, plugin SDK, protocol, SQLite schema, migration, or feature boundary changes are introduced.

User Impact

Operators can create and verify a backup while the gateway is running. Durable application and plugin SQLite data remains included.

Release-note context: live backups now omit disposable gateway/device coordination databases and their sidecars instead of failing on their locks. Per repository policy, this context is recorded here rather than editing CHANGELOG.md.

Evidence

  • Blacksmith Testbox: https://github.com/openclaw/openclaw/actions/runs/31058113916
    • Exact synced patch digest: e8c677384149687aebe7c1774b79e77cf3d75a701281a3de3ff6559db7432b05
    • src/infra/backup-volatile-filter.test.ts: 52 passed
    • src/infra/backup-create.test.ts: 70 passed
    • src/commands/backup-verify.test.ts: 28 passed, 1 platform-specific skip
    • Workflow and job both completed successfully.
  • Focused local proof on the final head:
    • transient classifier: 13 passed
    • verification transient case: 1 passed
    • held live coordinator and durable plugin continuity: 2 passed
  • oxlint and git diff --check: passed.
  • Autoreview:
    • Command: .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main --max-priority P1
    • Result: no P0/P1 findings, patch is correct, confidence 0.9; TruffleHog clean.

Maintainer Notes

  • Root cause: backup discovery treated zero-byte gateway/device SQLite coordinator databases as durable databases and attempted safe compaction while the running gateway intentionally held them open.
  • Architectural owner: src/infra/backup-volatile-filter.ts, consumed by backup discovery and tar filtering; verification shares only the reindex transient contract.
  • Canonical fix: one shared classifier, exact coordinator basenames, authoritative coordinator directories, and the canonical infra path-containment guard.
  • Removed paths: duplicated SQLite transient constants and exclusion branches in backup creation and verification; no fallback or compatibility path was added.
  • Production LOC: +49/-31 (+18 net), justified by the authoritative dual-lock-directory ownership boundary and shared classifier.
  • Test LOC: +179/-5 (+174 net).
  • Sibling coverage: gateway config/state locks, device identity locks, WAL/SHM/journal sidecars, reindex scratch databases, durable plugin databases, producer-shaped databases outside coordinator roots, and retained SQLite files colocated in coordinator directories.
  • Observed behavior: a backup completes and verifies while a real gateway coordinator database is held open; durable SQLite archives remain readable and transaction-consistent.

Punchcard-Session: amber-meadow-timber-8r

Reported by @AgentSolomon in #119757.

Fixes #119757

Punchcard-Session: amber-meadow-timber-8r
@vincentkoc vincentkoc self-assigned this Aug 6, 2026
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: M maintainer Maintainer-authored PR labels Aug 6, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head e8dfaf60663131a03a8c1437a715af7226240093.

@clawsweeper

clawsweeper Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper

clawsweeper Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 10:41 PM ET / August 6, 2026, 02:41 UTC.

ClawSweeper review

What this changes

The PR excludes disposable gateway and device coordinator SQLite lock files from backup discovery and archiving so backups can run while the gateway is active.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this maintainer PR open. The exact-head patch is a coherent root-boundary repair with no actionable code finding, but it is behind current main and its exact-head checks are still running.

Priority: P2
Reviewed head: e8dfaf60663131a03a8c1437a715af7226240093

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The repair is well-scoped and source-supported, with no actionable diff defect found; current-base CI completion remains the merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: The author is a repository member and the PR carries the maintainer label, so the external-contributor proof gate does not apply; its claimed held-lock regression coverage remains useful supplemental evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The author is a repository member and the PR carries the maintainer label, so the external-contributor proof gate does not apply; its claimed held-lock regression coverage remains useful supplemental evidence.
Evidence reviewed 6 items Current-main failure path: Current main recursively discovers SQLite files and snapshots them; a held coordinator database therefore reaches the safe-compaction failure path because only reindex transients are excluded.
Producer contract: Gateway and device coordinators produce the exact lock-database names addressed by the PR, under the ephemeral gateway lock root.
Canonical repair boundary: The PR centralizes exact coordinator-name and authoritative-root classification, then applies it before SQLite snapshotting and again during archive filtering while retaining globally identifiable reindex exclusions.
Findings None None.
Security None None.

How this fits together

Backup creation discovers state files, safely snapshots durable SQLite databases, and writes a verified archive. Gateway and device coordinators create disposable SQLite lock files that must be excluded before the durable-data backup path begins.

flowchart LR
  A[Running gateway] --> B[Coordinator lock databases]
  C[Backup discovery] --> D[Transient SQLite classifier]
  B --> D
  D -->|exclude transient files| E[Durable SQLite snapshot]
  E --> F[Verified backup archive]
Loading

Before merge

  • Resolve merge risk (P1) - The PR is behind current main and required exact-head checks remain in progress; merge only after current-base validation completes.
  • Complete next step (P2) - No mechanical repair is needed; the protected maintainer PR needs its in-progress exact-head checks and current-base validation completed before merge.
Agent review details

Security

None.

PR surface

Source +18, Tests +174. Total +192 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 49 31 +18
Tests 3 179 5 +174
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 228 36 +192

Review metrics

Metric Value Why it matters
Production versus test LOC production +49/-31 (net +18); tests +179/-5 (net +174) The production growth is justified by one shared ownership boundary; the larger test change covers live locks, sidecars, and durable SQLite retention.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/backup-verify.test.ts, migration/backfill/repair: src/commands/backup-verify.ts, migration/backfill/repair: src/infra/backup-create.ts, migration/backfill/repair: src/infra/backup-volatile-filter.test.ts, migration/backfill/repair: src/infra/backup-volatile-filter.ts, persistent cache schema: src/infra/backup-create.test.ts, and 2 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #119757
Summary: This PR is the active candidate fix for the reported running-gateway backup failure.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the shared classifier after a clean current-main validation, preserving its exact producer-name and authoritative-root boundary rather than using a broad .lock.sqlite exclusion.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the shared classifier after a clean current-main validation, preserving its exact producer-name and authoritative-root boundary rather than using a broad .lock.sqlite exclusion.

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

Yes—source establishes that current main classifies the held coordinator SQLite file as a snapshot input, while its producer holds that file for the gateway lifetime. The linked report independently supplies the observed locked-database failure on an official beta build.

Is this the best way to solve the issue?

Yes—the shared classifier at the backup volatile-file boundary is the narrowest maintainable fix because it covers discovery and archive filtering while retaining lock-shaped durable databases outside authoritative coordinator roots.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c37ba84f662a.

Labels

Label changes:

  • add P2: This repairs a bounded but real operator backup failure while a gateway is running.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The author is a repository member and the PR carries the maintainer label, so the external-contributor proof gate does not apply; its claimed held-lock regression coverage remains useful supplemental evidence.

Label justifications:

  • P2: This repairs a bounded but real operator backup failure while a gateway is running.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The author is a repository member and the PR carries the maintainer label, so the external-contributor proof gate does not apply; its claimed held-lock regression coverage remains useful supplemental evidence.

Evidence

What I checked:

  • Current-main failure path: Current main recursively discovers SQLite files and snapshots them; a held coordinator database therefore reaches the safe-compaction failure path because only reindex transients are excluded. (src/infra/backup-create.ts:472, c37ba84f662a)
  • Producer contract: Gateway and device coordinators produce the exact lock-database names addressed by the PR, under the ephemeral gateway lock root. (src/infra/gateway-lock.ts:488, c37ba84f662a)
  • Canonical repair boundary: The PR centralizes exact coordinator-name and authoritative-root classification, then applies it before SQLite snapshotting and again during archive filtering while retaining globally identifiable reindex exclusions. (src/infra/backup-volatile-filter.ts:48, e8dfaf606631)
  • Regression coverage: The new boundary test holds a real gateway coordinator, verifies that its sidecars are omitted, and confirms durable and lookalike SQLite data remains archived and readable. (src/infra/backup-create.test.ts:2031, e8dfaf606631)
  • Feature provenance: Blame attributes the current backup and coordinator baseline to the managed-service lifecycle refactor, establishing the recent owner trail without attributing fault. (src/infra/backup-create.ts:472, 36554c282008)
  • Current-base and release check: The three-way merge is conflict-free, but the head is behind current main and the fix is not present in the supplied latest release; it remains an unmerged repair requiring exact-current-base validation. (src/infra/backup-create.ts:446, e8dfaf606631)

Likely related people:

  • steipete: Current source blame connects the coordinator and backup baseline to the managed-service lifecycle refactor. (role: recent lifecycle and backup-area contributor; confidence: high; commits: 36554c282008; files: src/infra/backup-create.ts, src/infra/gateway-lock.ts, src/infra/device-identity-coordinator.ts)
  • vincentkoc: Merged history includes prior backup snapshot work, and this repair continues that owner boundary. (role: backup snapshot contributor; confidence: medium; commits: f1afaa3; files: src/infra/backup-create.ts, src/infra/backup-volatile-filter.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the exact-head checks complete and validate the clean merge result against current main before merging.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-06T00:27:50.057Z sha e8dfaf6 :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc marked this pull request as ready for review August 6, 2026 02:36
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Aug 6, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

Current-base validation is complete for the remaining owner/rank-up move.

  • Owner decision: PR marked ready for review.
  • Reviewed and hosted head: e8dfaf60663131a03a8c1437a715af7226240093 (unchanged).
  • Current origin/main: 465544792c8ae28f418802eec1db1becaf0754ff.
  • Exact-head GitHub CI: 194 checks, 0 pending, 0 attention.
  • OPENCLAW_TESTBOX=1 scripts/pr prepare-run 119782: passed with hosted CI/Testbox gates passed and prepare-run complete.
  • Current-main drift: 15 commits, with zero touched-path overlap against this PR's backup surface.

This satisfies the requested equivalent current-base validation without rebasing or changing the reviewed head.

@vincentkoc
vincentkoc merged commit 63cadcf into main Aug 6, 2026
194 checks passed
@vincentkoc
vincentkoc deleted the fix/backup-transient-lock-sqlite branch August 6, 2026 03:26
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 6, 2026
vincentkoc added a commit to VACInc/openclaw that referenced this pull request Aug 6, 2026
…cope

* origin/main: (24 commits)
  fix(backup): skip transient gateway lock databases (openclaw#119782)
  test(agents): use canonical auth session fixtures (openclaw#119821)
  fix(memory): keep QMD file hints after stale docid misses (issue openclaw#113041) (openclaw#113515)
  test(doctor): align fast-path repair contracts (openclaw#119812)
  perf(agents): index subagent recovery ownership (openclaw#119793)
  fix(gateway): keep chat startup off catalog discovery (openclaw#119742)
  fix(test): keep TUI PTY suites in their owner lane (openclaw#119787)
  docs: correct dashboard auth precedence (openclaw#119785)
  docs: document control ui owner handoff
  fix: grant host-authorized control ui owner access
  fix(worktrees): preserve registered roots during orphan cleanup (openclaw#119709)
  fix(matrix): prevent shared client key collisions (openclaw#119667)
  fix(diagnostics-otel): propagate exported span context (openclaw#112283)
  fix(worker): isolate state observer failures (openclaw#117507)
  fix(qa): attest realized profile executions (openclaw#119761)
  fix(gateway): finish successful sessions after timestamp races (openclaw#119752)
  fix(agents): fence restart recovery lifecycle (openclaw#119776)
  fix(ui): preserve chat history and active run timing (openclaw#119729)
  improve(ollama): reduce inactive startup cost (openclaw#119745)
  improve(gateway): defer inactive plugin runtime imports (openclaw#119733)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

backup create fails on running gateway's ephemeral lock database

1 participant