Skip to content

feat(prebuilt): reap abandoned extraction staging directories (#1882) - #2179

Merged
zackees merged 1 commit into
mainfrom
agent/1882-staging-gc
Nov 26, 2026
Merged

zackees merged 1 commit into
mainfrom
agent/1882-staging-gc

Conversation

@zackees

@zackees zackees commented Nov 25, 2026

Copy link
Copy Markdown
Member

Unit 9 of #1882 — staging/partial GC

extract stages into .<first 16 hex of sha256>.<attempt>.staging next to the
destination and removes it on every ordinary error path, but a process killed
outright (SIGKILL, OOM killer, reboot) cannot run that cleanup — so each kill
leaves a directory holding up to MAX_EXTRACTED_BYTES (16 GiB) forever.
This unit reaps exactly those directories and nothing else.

crates/fbuild-packages-fetch/src/prebuilt/gc.rs + gc_tests.rs:

rule behaviour
candidate name must be exactly .<16 lowercase hex>.<decimal attempt>.staging; a destination tree, a marker, a .bak, an uppercase or wrong-width digest, a non-numeric attempt and a same-shaped file are all left alone
type only a real directory is removed — symlink_metadata first, so a symlink with a candidate name is never followed and never unlinked (its target survives)
age a candidate younger than MIN_AGE (1 h) is kept; an unreadable or future mtime is also kept, because guessing "old" is the unsafe direction
marker a candidate holding .prebuilt-tree.json is kept and reported — a verified tree that was never committed is the caller's decision to discard, not a sweep's
bound one sweep removes at most MAX_REMOVALS (32) directories, so a cache with many abandoned attempts cannot turn one call into an unbounded delete
report SweepReport { removed, freed_bytes, kept_live, kept_marked }; a removal error is returned with its path, never swallowed
async sweep_staging_async runs the blocking pass on its own thread for daemon callers

Opt-in only: no extraction calls it implicitly, so a live attempt in another
process is never at risk (that separation is also what makes the grace period
testable without touching file times — the tests drive an explicit clock).

Verification (head as pushed)

  • soldr cargo test -p fbuild-packages-fetch --lib → 360 passed / 0 failed / 2 ignored (10 of them new, all in prebuilt::gc).
  • RED proven by mutation, each restored afterwards:
    • grace period disabled → a_fresh_staging_directory_is_kept_for_a_live_extraction FAIL (9/1);
    • marker guard disabled → a_staging_directory_holding_a_marker_is_kept_and_reported FAIL (9/1);
    • name-shape guard disabled → a_completed_tree_and_foreign_names_are_never_touched + a_symlink_named_like_staging_is_not_followed_or_unlinked FAIL (8/2).
  • soldr cargo clippy -p fbuild-packages-fetch --all-targets -- -D warnings exit 0.
  • soldr cargo fmt --all -- --check exit 0.
  • ci/enforce_platform_boundary.py --print-totals rc 0 (rows=0; dylint_rows=0, identical to origin/main), ci.test_enforce_platform_boundary 14 tests OK, ci/platform_boundary_research.py --check rc 0, ci/check_test_layout.py rc 0.

No wiring change: the daemon call site (sweep at startup) is the follow-up cell,
alongside the disk-cache LRU and the bucket key. #1882 stays open (remaining
cells: disk-cache LRU, the per-request BuildRequest field, the bucket key,
daemon-wide single-flight, and the --prebuilt-core consumer in the esp32
orchestrator).

@zackees

zackees commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

Attempt 2 (gh run rerun --failed on 45563505699, run attempt 2) died in the same step as attempt 1: linux / Check → Test, 5m31s, on dell-fsx3mn2-fastled-1, exit 101 at [email protected] after soldr: lost the connection to the soldr daemon (route soldr-daemon-7f93f978…) after 5.2s: Connection reset by peer (0 HIT / 25 MISS). Nothing in this diff is involved: every other check on this PR is green at 307e13d5.

The gate is infra, and there is now hard evidence it is load-driven, not a dead daemon — a green 21-minute linux / Check ran on the same host at load ≈ 5 five minutes earlier, while this one died at load 18.1. Details in #2178 comment 6. No further reruns from the steward on this class; the PR needs one green linux / Check once the Dell lane is healthy or unloaded.

@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 26, 2026
@zackees
zackees added this pull request to the merge queue Nov 26, 2026
Merged via the queue into main with commit 2318f74 Nov 26, 2026
74 of 80 checks passed
@zackees zackees mentioned this pull request Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant