fix(backup): retry fs.rm on EBUSY to prevent tar retry-loop collapse on Windows#101419
fix(backup): retry fs.rm on EBUSY to prevent tar retry-loop collapse on Windows#101419chenxiaoyu209 wants to merge 1 commit into
Conversation
…on Windows On Windows, fs.rm can throw EBUSY when the runTar process still holds a file descriptor. The old code caught and logged the error but left the locked file behind, causing the next runTar attempt to fail immediately and defeating the BACKUP_TAR_BACKOFF_MS retry mechanism. Fix: wrap fs.rm in a removeTempArchive helper that retries up to 3 times with a 100ms sleep on EBUSY, giving the OS time to release the handle. Fixes openclaw#101382. Co-Authored-By: Claude <[email protected]>
|
Codex review: needs real behavior proof before merge. Reviewed July 7, 2026, 2:44 AM ET / 06:44 UTC. Summary PR surface: Source +24. Total +24 across 1 file. Reproducibility: yes. for a source-level path: current main reuses one temp archive path, catches cleanup failure, and retries tar against the same path. I did not establish a live Windows EBUSY race in this read-only review. Review metrics: 2 noteworthy metrics.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review findings
Review detailsBest possible solution: Use a single canonical fix that makes each tar attempt independent of a locked partial archive, or retries cleanup after the outer backoff immediately before reuse, with focused regression coverage and redacted Windows backup proof. Do we have a high-confidence way to reproduce the issue? Yes for a source-level path: current main reuses one temp archive path, catches cleanup failure, and retries tar against the same path. I did not establish a live Windows EBUSY race in this read-only review. Is this the best way to solve the issue? No. A short cleanup retry is a plausible mitigation, but the safer fix is to avoid reusing a locked partial archive or retry cleanup after the outer backoff immediately before reuse. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against de152b1f65a6. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +24. Total +24 across 1 file. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
|
Closing as a duplicate of #101397. Both PRs change the same Thank you for the focused diagnosis. A distinct reproduction outside this temp-archive cleanup site would be new evidence to reopen or split follow-up work. |
What Problem This Solves
On Windows,
fs.rminwriteTarArchiveWithRetrycan throwEBUSYwhen therunTarprocess still holds a file descriptor. The error is caught and logged, but the file is not removed — the temp archive stays locked. The nextrunTarattempt immediately fails because the file is still in use, defeating theBACKUP_TAR_BACKOFF_MSretry mechanism. Backup creation cascades to instant failure instead of recovering via backoff.Fixes #101382.
Why This Change Was Made
Root cause: In the cleanup path between tar retries (
src/infra/backup-create.ts:191),fs.rmonly attempts removal once. On Windows, a file locked by another process handle returnsEBUSY. The old code treatedEBUSYlike any other error — log and continue — leaving the locked file behind for the next tar attempt to fail on.Fix: Extract
fs.rminto aremoveTempArchivehelper that retries up to 3 times with a 100ms sleep when the error isEBUSY, giving the OS time to release the file handle before the outer loop sleeps (10s/20s) and retries tar.User Impact
EBUSYis Windows-specific.Evidence
src/infra/backup-create.test.ts— 39 tests passedgit diff --checkclean🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]