Commit c0d812f
Killed test runs leak their GOTMPDIR work dirs: 27 abandoned /var/tmp/gotmp/go-build* trees held 4.5G and ENOSPC-failed a push gate that passed 10/10 after reclaim (gc-68bao) (#176)
* fix(scripts): reclaim leaked go-build/go-link temp trees in the harness sweep (gc-68bao)
go removes its per-invocation compile/link work dir under $GOTMPDIR only on a
clean exit. A run the harness watchdog kills (SIGQUIT->SIGKILL), a signalled
run, or an OOM kill leaks the tree, and nothing sweeps it. gc-68bao measured 27
such trees holding 4.5G that ENOSPC-failed a push gate which then passed 10/10
once they were reclaimed; the linker's go-link-* trees are the largest single
hoard. The trees appear both under $GOTMPDIR and, when a run set no GOTMPDIR,
directly under /var/tmp.
The process sweep in scripts/lib/harness-reap.sh already reaps stranded test
processes at gate start but never their leaked directories. This adds
gc_harness_sweep_stale_build_dirs there, called from test-local-parallel (the
one funnel all four heavy gate targets pass through) right after the process
sweep and on the same age floor, so the reclaim runs on every gate without a
new order or command.
The reclaim is deliberately bounded to go's own go-build*/go-link* shapes. That
bound is the safety argument: those prefixes are go-owned, never a checkout, a
cache-with-value, or a comparison base a human wants kept, and are regenerated
on the next build, so removing one needs no per-shape judgment. A tree is
reclaimed only when it is owned by the invoking user, older than the go test
budget, and referenced by no live process — the environ+cmdline+cwd /proc
predicate proven safe in gc-68bao (it spared every live build across two
concurrent gates). Every delete routes through the single gc_harness_reclaim_dir
seam, mirroring gc_harness_kill_pid, so the destroy authority is reviewable in
isolation and the self-test records decisions instead of removing real trees.
Scope: gc-68bao's notes also describe a larger /var/tmp half — gocache-* and
cold-build throwaway caches, 12.6G in one incident. A naive age+liveness scan of
that class was measured against the real host and matched 662 owned dirs of
mixed provenance, including comparison bases; encoding an unconditional rm -rf
of that set on every fleet gate is an unrecoverable blast radius and a policy
call, so it is filed as gc-ulys6 rather than shipped here.
Validation: new self-test TestHarnessSweepReclaimsLeakedGoWorkDirsButSparesLiveAndProtected
(reclaims an abandoned tree at either root; spares a live-held tree, a too-young
tree, a non-go shape, and a .git-bearing dir). go vet clean; scripts
harness/budget/tmpdir suites green. A print-only dry run over the real host
/var/tmp selected exactly the ~10 real leaked go trees and none of the 662 other
dirs.
Follow-up: gc-ulys6 (the /var/tmp agent-cache half).
* test(census): bump subprocess baselines for the new harness sweep test (gc-68bao)
The fix commit added buildDirSweepHarness to scripts/harness_reap_test.go,
a fifth exec.Command("bash", ...) call that shells out to exercise
gc_harness_sweep_stale_build_dirs. That file is untagged (no //go:build
constraint), so the new call lands in the untagged subprocess census and
trips resourcecensus's "totals cannot grow" ratchet:
TestRepositoryLedgerMatchesCensusAndDocumentation went red with the scanned
count one above the checked baseline on three rows.
The ledger, the bootstrap policy, and the rendered doc are three mirrors that
comparePolicyFields/validateBaseline require to agree exactly, so the +1 is
applied to all three: test/test-resources.toml and census.go's bootstrapPolicy
(baseline_calls 649->650 all-source, 432->433 untagged source, 425->426
untagged Small), then TESTING.md regenerated via the -update flag. Only
baseline_calls moves; baseline_files is unchanged because the call joined a
file already counted, and the historical reported_* columns are left as-is.
The new subprocess is a legitimate test harness that runs a shell function, so
raising the ratcheted baseline is the sanctioned path (the fixed-sleep census
is the one you shrink instead). Validation: full
internal/testpolicy/resourcecensus package green without -update, go vet clean,
and the deliverable's own TestHarnessSweepReclaimsLeakedGoWorkDirsButSparesLiveAndProtected
still passes.
* docs(scripts): state current behavior in harness-sweep comments
The go work-dir sweep's living comments carried a bead id and incident
history — measured hoard sizes, gate pass/fail counts, a follow-up policy
note. Convention is that comments state what is true now and the
constraints it rests on; history belongs in the bead and the commit log.
Rewrite the four comment blocks in scripts/lib/harness-reap.sh,
scripts/test-local-parallel, and scripts/harness_reap_test.go to state
only the reclaim's behavior and safety contract: it reclaims stale
same-UID go-build/go-link temp dirs after age and live-reference checks,
scans each caller-named root at depth 1, and leaves broader cache-root
cleanup out of scope. No behavior change.
Addresses pre-open signoff finding (round 1) on polecat/gc-68bao.
* fix(scripts): reclaim only go's exact go-build<n>/go-link-<n> shapes (gc-68bao)
The sweep matched the bare go-build*/go-link* prefix, so an old,
unreferenced human-named scratch dir such as go-build-base was selected
and rm -rf'd. go names its work dirs with os.MkdirTemp(dir, "go-build")
and os.MkdirTemp(dir, "go-link-"), which append a decimal suffix, so the
only go-owned shapes are go-build<digits> and go-link-<digits>. Match
exactly those.
The regression test renames its spare fixtures to valid go shapes so the
liveness/age/.git predicates (not shape) do the sparing, and adds
prefix-but-not-generated-shape cases the old glob would have reclaimed.
---------
Co-authored-by: refinery costing <refinery@local>
Rebased 2026-09-15 onto upstream 83c8270: the resource-census +1 hunks
(census.go, test-resources.toml, TESTING.md) were deltas on the previous
sync's baselines and are re-derived over the merged tree in the census
commit at the end of this rebase; the reaper, its test and the
test-local-parallel sweep call merged unchanged.
Claude-Session: https://claude.ai/code/session_01XfZfLDuwcBfs3TXnn1udn91 parent 7527859 commit c0d812f
3 files changed
Lines changed: 237 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
459 | 460 | | |
460 | 461 | | |
461 | 462 | | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
290 | 300 | | |
291 | 301 | | |
292 | 302 | | |
| |||
0 commit comments