Skip to content

fix(backup): truncated archive verification hangs before restore - #188948

Merged
roboclaw-bot merged 1 commit into
mainfrom
openclaw/fix-backup-truncated-archive-consumers
Oct 31, 2026
Merged

roboclaw-bot merged 1 commit into
mainfrom
openclaw/fix-backup-truncated-archive-consumers

Conversation

@roboclaw-bot

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes backup verification hanging before restore when a PostgreSQL archive has a truncated gzip stream.

User Impact

Damaged archives now fail promptly and close their temporary file handles. Archive verification keeps its existing single-pass behavior and corruption checks.

Why This Change Was Made

The streamed verification introduced in #188518 could throw while canceling an entry without an error listener, leaving another consumer waiting with an open file handle. Cancel every active consumer without re-emitting the error, then stop reading if cancellation occurs during a file write. The existing corruption test also checks that all opened handles close.

Evidence

  • Reproduced the original truncated-archive case timing out at 120 seconds before the fix. It now rejects in 81 ms on pinned Bun and 69 ms on Node 24.22.1.
  • Pinned Bun: 101 tests passed across seven focused backup and startup-recovery files; one existing Windows-only long-path test skipped. Node 24.22.1: all 31 completeness tests passed.
  • Scoped TypeScript, lint, format, test-line and line-cap ratchets, and diff checks passed. No timeout, retry, skip, assertion weakening or baseline increase.
  • Fresh independent canonical autoreview of the accepted two-file patch: P0–P2, complete, no actionable findings. pr-simplify completed. Published source is verified against that accepted patch.
  • Linux proof covers archive verification and staging restore; the existing Windows-only case was not exercised. Exact-head PR CI supplies broader proof.

Requested by @steipete

Work sessions

Discussion, implementation and verification

Cancel every active entry without re-emitting an unhandled error, and stop
spool iteration when cancellation arrives during a file write. Preserve the
parser failure while joining consumers and closing all spool handles.

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

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

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: XS labels Oct 31, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review October 31, 2026 01:54
@roboclaw-bot
roboclaw-bot enabled auto-merge (squash) October 31, 2026 01:58
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug 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-repro Preliminary submission classification; full source review pending. labels Oct 31, 2026
@clawsweeper

clawsweeper Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR settles active archive consumers after parsing fails and verifies that temporary file handles close.

Example: Verify a PostgreSQL backup whose gzip stream has its final 16 bytes removed.

  • Before: Verification can hang while awaiting consumers with open temporary files.
  • After: Verification rejects the damaged archive after consumers settle and close their handles.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and source-supported, with meaningful handle-cleanup coverage; inspectable evidence remains at the in-process boundary.
Proof confidence 🦐 gold shrimp (3/6) This collaborator-authored PR is outside the ordinary proof gate; supplied Bun and Node results describe the changed verifier rejecting truncated gzip and closing handles, but no terminal artifact independently demonstrates the shipped CLI.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A damaged backup can leave verification waiting indefinitely before restore begins.
Reason: Promptly rejecting corrupt archives restores the documented verification contract, and collaborator authorship establishes the repair direction.

Regression provenance

Regression provenance — verified: source commit a1d51cede5e0 by Peter Steinberger; canonical PR #188518 (blame-to-merge-commit).

Merge readiness

✅ Ready for maintainer review

Keep open: this PR narrowly repairs a current-main archive-verification hang, preserves existing validation, and introduces no identified defects.

Priority: P2
Reviewed head: eeba0e31ca8cfff9f00c17f9fa424175546975c9

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No publicly inspectable shipped-CLI trace shows a truncated archive rejecting after the fix; the reported reproduction exercises the production verifier in tests.
Agent review details

How this fits together

Backup verify, create with verification, and restore share the archive verifier, which streams tar entries into private scratch before validating database artifacts.

flowchart TD
  A[Backup commands] --> B[Archive verifier]
  B --> C[Tar inventory reader]
  C --> D[Manifest consumer]
  C --> E[Database spool]
  D --> F[Validation or parse failure]
  E --> F
  F --> G[Consumer settlement and scratch cleanup]
Loading

Technical review

Best possible solution:

Keep cancellation and handle settlement in the existing archive reader and spool, preserving the original parse failure and all validation checks.

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

Current-main cancellation and the pinned Minipass iterator contract establish the failure path; the author reports a matching before-and-after reproduction, which this read-only review did not execute.

Is this the best way to solve the issue?

This is the smallest complete repair: cancel every active consumer, avoid another iterator read after destruction, and retain the existing finally-based handle cleanup.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Streamed archive consumption and spool lifecycle keeps the original intent (a1d51ce: Avoid repeated decompression by retaining database artifacts during the inventory pass while preserving verification and cleanup.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Focused cancellation repair: The introduced diff cancels entries without emitting another error and checks destruction after awaited writes; the original parser error remains authoritative while consumers are joined. (src/commands/backup-verify-spool.ts:251, eeba0e31ca8c)
  • Current-main failure path: Fetched main still passes the parser error into entry.destroy and lacks the post-write destruction check. (src/commands/backup-verify-spool.ts:246, 5ca51dcffd9c)
  • Runtime cancellation contract: OpenClaw's locked tar dependency uses Minipass 7.1.3. Its destroy(error) emits an error, iterator data delivery removes the error listener, and next() does not check an already-destroyed stream before waiting; these contracts support both repair hunks. (src/index.ts:1200, ab4b3b05d0d5)
  • Regression coverage: The existing damaged-archive cases use real tar and filesystem operations; the added observation asserts that every opened file handle is closed after verification rejects. (src/commands/backup-verify-completeness.test.ts:500, eeba0e31ca8c)
  • Original intent and feature history: fix: avoid repeated decompression when verifying backups #188518 introduced streamed spooling to avoid repeated decompression while preserving corruption checks; this PR repairs that lifecycle without reversing its design. (src/commands/backup-verify-spool.ts:99, a1d51cede5e0)
  • Discussion and supplied validation: The full body reports the original timeout and successful Bun and Node verifier runs; comments contain status updates rather than additional proof. Collaborator authorship establishes direction and the keep-open guard. (eeba0e31ca8c)

Likely related people:

  • Peter Steinberger: Raw commit a1d51ce adds src/commands/backup-verify-spool.ts:99 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a1d51cede5e0; files: src/commands/backup-verify-spool.ts)
  • Jason (Json): Raw commit 28d3296 adds src/commands/backup-verify-completeness.test.ts:77 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 28d3296aaf2b; files: src/commands/backup-verify-completeness.test.ts)

PR surface

Source +5, Tests +8. Total +13 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 6 1 +5
Tests 1 8 0 +8
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 14 1 +13

Labels

Label changes:

  • add P2: Damaged archives can hang verification and block restore preparation, with impact limited to this failure path.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Damaged archives can hang verification and block restore preparation, with impact limited to this failure path.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦞 diamond lobster.
  • 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 30, 2026, 10:10 PM ET / October 31, 2026, 02:10 UTC.

@roboclaw-bot
roboclaw-bot merged commit 59bb137 into main Oct 31, 2026
204 checks passed
@roboclaw-bot
roboclaw-bot deleted the openclaw/fix-backup-truncated-archive-consumers branch October 31, 2026 02:17
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
…188948)

## What Problem This Solves

Fixes backup verification hanging before restore when a PostgreSQL archive has a truncated gzip stream.

## User Impact

Damaged archives now fail promptly and close their temporary file handles. Archive verification keeps its existing single-pass behavior and corruption checks.

## Why This Change Was Made

The streamed verification introduced in openclaw#188518 could throw while canceling an entry without an error listener, leaving another consumer waiting with an open file handle. Cancel every active consumer without re-emitting the error, then stop reading if cancellation occurs during a file write. The existing corruption test also checks that all opened handles close.

## Evidence

- Reproduced the original truncated-archive case timing out at 120 seconds before the fix. It now rejects in 81 ms on pinned Bun and 69 ms on Node 24.22.1.
- Pinned Bun: 101 tests passed across seven focused backup and startup-recovery files; one existing Windows-only long-path test skipped. Node 24.22.1: all 31 completeness tests passed.
- Scoped TypeScript, lint, format, test-line and line-cap ratchets, and diff checks passed. No timeout, retry, skip, assertion weakening or baseline increase.
- Fresh independent canonical autoreview of the accepted two-file patch: P0–P2, complete, no actionable findings. pr-simplify completed. Published source is verified against that accepted patch.
- Linux proof covers archive verification and staging restore; the existing Windows-only case was not exercised. Exact-head PR CI supplies broader proof.

Requested by @steipete
## Work sessions

[Discussion, implementation and verification](https://team.openclaw.ai/chat/roboclaw/~key/dashboard/b5679712-7777-4ff7-a05a-81c1efab2069)

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

Labels

commands Command implementations P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS 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