You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dig-node#361 fixed the temp-directory leak that took the dev machine to ENOSPC — the ~57 MB-per-node dig-node-serve-test-* tree in crates/dig-node-service/tests/content_serve.rs. It deliberately did not widen into the rest of the workspace.
This ticket closes the remainder, as a named finite list rather than a sweep.
Context — there is no shared helper, and that was the surprising part
#361 hypothesised a shared helper. There isn't one: every site is a hand-rolled std::env::temp_dir().join(format!(..)), roughly 50 across the workspace, each independently
missing its cleanup. So the fix is per-site, and the list below is the whole of it.
One exception is worth knowing, because it collapses two of the ticket's rows into a single edit: dig-node-auth* and dig-node-custody* are both produced by the same function — crates/dig-node-core/src/peer.rs's fresh_pool_handle_on(tag, ..), building dig-node-{tag}-{pid}.
The list
prefix
file
note
dig-node-test-*
crates/dig-node-service/tests/server.rs (4 sites)
0.77 GB / 6,701 dirs — the only remaining one with real bytes.base outlives the block that creates it (state is returned from it), so a guard needs a signature change on those helpers, not just a TempDir
Roughly 38,000 directories in total. Bytes are near zero for everything except dig-node-test-* — these matter because ~50,000 entries make every Temp scan slow and make the
next real leak hard to see, which is exactly what delayed the #361 diagnosis (the first diagnosis
blamed worktree target/ dirs, which were not the cause).
Reference of "good"
content_serve.rs's NodeCache on #368. Two properties are the point, and a fix that has
neither is not a fix:
The guard owns the directory (tempfile::TempDir), so removal happens in Drop — including
on an unwind. A cleanup line at the end of a test is skipped by every failing assertion, i.e. the
runs a developer repeats; and a cleanup placed after an .await leaks on panic if anything
catches it.
The tests to copy are the_temp_tree_is_removed_on_drop_and_on_panic and the_sweep_removes_an_abandoned_tree_and_spares_a_live_one. Note the second one's live-tree
control: a sweep that deleted everything would pass a "the stale one is gone" assertion while
removing a concurrent lane's working directory.
Scope
The simplest per-site change that gives property 1. Do not introduce a workspace-wide temp-dir
abstraction as part of this — several of these sites have genuinely different lifetimes (a returned GossipHandle, a returned state), and a shared type would have to model all of them before any
one leak is fixed.
dig-node-test-* first: it is the only one that costs disk.
Evidence
Per site: run its suite twice and show the Temp entry count for that prefix returns to its
pre-run value, or state the bound and why removal is impossible. A leak test bounded by its own
duration is not a test — assert on the path after the guard is gone, and include the panic path.
Done condition
Every row above is either fixed or has a stated, checkable bound, and a test asserts its own cleanup.
Task
dig-node#361 fixed the temp-directory leak that took the dev machine to
ENOSPC— the ~57 MB-per-nodedig-node-serve-test-*tree incrates/dig-node-service/tests/content_serve.rs. It deliberately didnot widen into the rest of the workspace.
This ticket closes the remainder, as a named finite list rather than a sweep.
Context — there is no shared helper, and that was the surprising part
#361 hypothesised a shared helper. There isn't one: every site is a hand-rolled
std::env::temp_dir().join(format!(..)), roughly 50 across the workspace, each independentlymissing its cleanup. So the fix is per-site, and the list below is the whole of it.
One exception is worth knowing, because it collapses two of the ticket's rows into a single edit:
dig-node-auth*anddig-node-custody*are both produced by the same function —crates/dig-node-core/src/peer.rs'sfresh_pool_handle_on(tag, ..), buildingdig-node-{tag}-{pid}.The list
dig-node-test-*crates/dig-node-service/tests/server.rs(4 sites)baseoutlives the block that creates it (stateis returned from it), so a guard needs a signature change on those helpers, not just aTempDirdig-node-dual-*,dig-node-dualstack-*crates/dig-node-service/tests/server.rsdig-node-{tag}-*(auth,custody,bootstrap,wuc,wuc-share)crates/dig-node-core/src/peer.rsGossipHandleuses the cert files for its lifetime, so the guard has to be held by the callerdig-tip-*(9,898 dirs)crates/dig-wallet/src/sage/tipping.rsdig-wallet-sup-*(3,659)crates/dig-wallet/src/sage/sync_supervisor/tests.rsdig-wallet-svc-*(1,354)crates/dig-wallet/src/sage/service.rsdig-wallet-rpc-authgate-*(2,585)crates/dig-wallet/src/sage/rpc.rsdig-watchlist-*crates/dig-wallet/src/sage/watchlist.rsRoughly 38,000 directories in total. Bytes are near zero for everything except
dig-node-test-*— these matter because ~50,000 entries make everyTempscan slow and make thenext real leak hard to see, which is exactly what delayed the #361 diagnosis (the first diagnosis
blamed worktree
target/dirs, which were not the cause).Reference of "good"
content_serve.rs'sNodeCacheon#368. Two properties are the point, and a fix that has
neither is not a fix:
tempfile::TempDir), so removal happens inDrop— includingon an unwind. A cleanup line at the end of a test is skipped by every failing assertion, i.e. the
runs a developer repeats; and a cleanup placed after an
.awaitleaks on panic if anythingcatches it.
wallet.sqliteis held by the detached serve task), the residue is bounded and stated, notpretended away. fix(test): serve integration test leaks a ~57MB temp dir per run — 1,123 dirs / 62.5 GB took the machine to ENOSPC #361 uses a once-per-process sweep over trees idle longer than any live run.
The tests to copy are
the_temp_tree_is_removed_on_drop_and_on_panicandthe_sweep_removes_an_abandoned_tree_and_spares_a_live_one. Note the second one's live-treecontrol: a sweep that deleted everything would pass a "the stale one is gone" assertion while
removing a concurrent lane's working directory.
Scope
The simplest per-site change that gives property 1. Do not introduce a workspace-wide temp-dir
abstraction as part of this — several of these sites have genuinely different lifetimes (a returned
GossipHandle, a returnedstate), and a shared type would have to model all of them before anyone leak is fixed.
dig-node-test-*first: it is the only one that costs disk.Evidence
Per site: run its suite twice and show the
Tempentry count for that prefix returns to itspre-run value, or state the bound and why removal is impossible. A leak test bounded by its own
duration is not a test — assert on the path after the guard is gone, and include the panic path.
Done condition
Every row above is either fixed or has a stated, checkable bound, and a test asserts its own cleanup.
Parent
https://github.com/DIG-Network/dig_ecosystem/issues/2790
Follows #361