8000 The suite fills the disk · Issue #599 · nixidae/nixidae · GitHub
[go: up one dir, main page]

Skip to content

The suite fills the disk #599

Closed
Closed

Description

@Lillecarl

DONE, 2026-09-06. Read the status section at the end first: the
premise of this opening paragraph is wrong, and the file records how
it was refuted rather than deleting it.

It said: the test suite leaves 463 MB in /tmp per run, and a failed
cleanup path lets that accumulate without bound. It reached 16 GB and
filled a 61 GB root, which stopped a build with a SIGBUS inside
sqlite.

The disk filling was real. The suite was not what filled it.

What was measured

On 2026-08-28, /tmp/pytest-of-lillecarl held 16 GB across 139
directories, every one of them named garbage-*. The disk was at
100%, 80 MB free.

The failure it caused is worth naming, because it does not look like
a disk problem:

nix::LocalStore::openDB -> sqlite3_exec -> Bus error (core dumped)

sqlite mmaps its database. A write to a mapped page with no space
behind it is SIGBUS, not ENOSPC, so a full disk arrives as a segfault
in a library that has nothing to do with the cause.

After deleting it, one clean run of nix run --file . test left
463 MB.

Where the 463 MB is

55 x 8.0M   nix/var/nix/db/reserved

nix::LocalStore pre-allocates a reserved file when it opens a store,
so it can free space during a garbage collection on a full disk. It is
8 MiB, and it is per STORE.

The chroot fixture in test_store.py is function-scoped over
tmp_path, so every test that asks for a real store gets its own
store, its own database and its own 8 MiB reservation. 55 of them in
one run.

libstore has a setting for this - reserved-size - and 0 is a legal
value for a store that is never garbage-collected. Whether the fixture
should set it, or share one store across a module, or something else,
is the decision this task is for. Sharing has a known hazard already
recorded in declare.py: two LocalStores in one process deadlock on a
temp-roots flock, so "just use a session fixture" is not free.

Where the 16 GB is

A different fault, and the one that actually matters, because 463 MB
per run is bounded and 16 GB is not.

pytest keeps the last three runs and removes the rest. When a removal
FAILS it renames the directory to garbage-* and tries again next
time. Every one of the 139 was a garbage-*, so removal had been
failing for a long time and each attempt only added another.

The warnings say why:

(rm_rf) error removing .../test_a_build_lands_in_the_uppe0/lower/nix/store/...-ncurses-6.6
  OSError: [Errno 30] Read-only file system
  OSError: [Errno 39] Directory not empty
  PermissionError: [Errno 13] Permission denied

Store paths are read-only by design, and a directory of them cannot be
removed without making it writable first. shutil.rmtree does not do
that, and neither does pytest.

test_a_build_lands_in_the_upper* does not exist in this repo any
more.
The name survives only in the leftover directories, so some of
those 139 are from a test that has since been renamed or deleted. That
does not make the fault historical: any test that copies store paths
into tmp_path reproduces it.

What to decide

  1. Should the fixture drop reserved-size, share a store, or neither?
    The flock hazard rules out the obvious version of sharing.
  2. Should a fixture make its tree writable before pytest tries to
    remove it? A chmod -R u+w finalizer is one line and it is the
    difference between bounded and unbounded growth.
  3. Is 463 MB per run acceptable once the growth is bounded? Three
    retained runs is 1.4 GB, which is fine on a big disk and not on a
    laptop.

What was NOT done

Nothing is fixed. The 16 GB was deleted so work could continue, and
that is all. The numbers above are from a clean run afterwards, so
they are current rather than remembered.

Remeasured on 2026-09-01, and two of the three answers change

The unbounded growth does not reproduce, and question 2 is closed

A chmod -R u+w finalizer was written, and then measured against the
version without it. They are identical. Five clean runs each,
from an empty /tmp/pytest-of-lillecarl:

with the fixture      pytest-2 pytest-3 pytest-4   0 garbage   1.4 GB
without the fixture   pytest-4 pytest-5 pytest-6   0 garbage   1.4 GB

pytest 9.1.1 already does it. _pytest/pathlib.py:on_rm_rf_error
catches PermissionError, chmods the path read-write, walks the
PARENTS for a file, and retries. That is the whole of what the
finalizer would have added.

The fault IS real and was reproduced directly - a store path that is
a DIRECTORY is r-xr-xr-x, and shutil.rmtree raises EACCES on it;
chmod u+w on directories alone fixes it. A read-only FILE unlinks
fine, because the permission that matters is the parent's. Seven
tests in the current suite add a directory to a store, so the shape
is live. pytest simply recovers from it.

So what made 16 GB was the errors pytest does NOT recover from, and
the task's own warnings name them:

OSError: [Errno 30] Read-only file system
OSError: [Errno 39] Directory not empty

Neither is a PermissionError, so line 94 of that handler warns and
gives up. EROFS is not a permission at all - no chmod fixes a
read-only FILESYSTEM - and the test it came from is
test_a_build_lands_in_the_uppe0, an OverlayFS test with a lower
layer. That test does not exist any more.

Do not add the finalizer. It costs a directory walk per test and
an empty tmp_path for every test that wanted none, and it fixes
nothing this pytest does not already fix. If an overlay test returns,
the fix is that test unmounting what it mounted, not a chmod.

Question 1 rests on a wrong premise

The setting is not reserved-size and it is not reachable from a
store URI. In nix 2.35 it is gc-reserved-space, declared on
GCSettings, and Settings in globals.hh privately inherits
LocalSettings which inherits that - so it is a GLOBAL nix setting,
not a per-store one. Measured, three spellings, all refused:

warning: unknown setting 'gc-reserved-space'
{d}?gc-reserved-space=0              reserved=8192 KiB
local?root={d}&gc-reserved-space=0   reserved=8192 KiB
{d}?reserved-size=0                  reserved=8192 KiB

So the fixture cannot ask for it. Setting it globally would need
binding surface this repo does not have, for a test-only concern.

What is actually left

Question 3 alone, and it is a judgement rather than a defect: 464 MB
per run, three runs retained, 1.4 GB steady. Bounded, and the
dangerous half is gone.

The 177 warnings are somebody else's, 2026-09-02

nix run --file . test now prints 237 passed, 177 warnings, every
one of them (rm_rf) error removing .../test_a_build_lands_in_the_uppe0/lower/nix/store/.... That is the
EROFS shape above, from the test this file already records as gone.

It is not this suite's. /tmp/pytest-of-lillecarl is keyed by USER,
not by project, so every pytest this machine runs shares it. The
directory holding those 2.2 GB also holds test_get_flake_local_0,
test_call_flake_local_0 and test_eval_flake_writes_lock_fi0, and
this repo has no flake tests at all. Another project left it, this
suite cannot delete it, and pytest scans the shared basedir on every
run and warns about it again.

Measured: 5.5 GB across 51 directories, of which

2.2 GB   one immortal garbage-* dir, another project's
1.6 GB   three retained runs of THIS suite, ~536 MB each
1.7 GB   older pytest-N husks

So the steady figure above still holds for this suite. What changed
is only that the noise is now loud enough to be blamed on it - which
is the reason to write this down rather than to fix anything.

A reader who sees the count should check WHOSE leftovers they are
before touching a fixture here. ls /tmp/pytest-of-lillecarl/<dir>
answers it in one command.

It stopped a build again, 2026-09-03

Still OPEN, and the cost is no longer hypothetical. It stopped
work in the middle of a perturbation run:

error: write of 62 bytes: No space left on device

/nix and / are one filesystem, so this is the same 61 GB. At the
moment it failed:

61 GB   size
 4.0 K  available, 100% used
7.2 GB  /tmp/pytest-of-lillecarl, 576 directories
2.2 GB  garbage-1ca72bea-...
2.2 GB  garbage-1fd4c0e5-...
562 MB  each of the three most recent pytest-N runs

Two immortal garbage-* dirs again, and 574 husks behind them.
Reclaiming all of it returned the disk to 92%, 4.6 GB free:

chmod -R u+w /tmp/pytest-of-lillecarl && rm -rf /tmp/pytest-of-lillecarl

Most of it was NOT this suite

Written first as "7.2 GB of it was this suite's leftovers", which
the evidence does not support. The 2026-09-01 section above already
said one garbage-* dir belonged to another project, and the same
is true of both today. Their contents name the test:

garbage-.../test_a_build_lands_in_the_uppe0/lower/nix/store/...

test_a_build_lands_in_the_upper* does not exist in this
repository - grepped, no match - which is exactly what that section
says, and an OverlayFS lower layer is not a shape anything here
builds. So 4.4 GB of the 7.2 GB is somebody else's, and this suite's
share is the ~2.8 GB of numbered husks.

The chmod is still the mechanism: rm -rf alone fails on a store
path that is a read-only DIRECTORY, which is why pytest's own
rm_rf needs its recovery path. But that recovery WORKS, per the
measurement above - what defeats it is EROFS and Directory not empty, and both came from the overlay test that is not ours.

What is unexplained, and stays that way

574 numbered dirs, where pytest retains three. That contradicts the
"three retained runs" figure this task has used since 2026-09-01,
and it is not diagnosed: the evidence was deleted to get the disk
back. Whether the older ones failed to prune or are near-empty
stubs is a measurement somebody has to take fresh - ls | wc -l
plus du -sh on the oldest, before reclaiming next time.

Recorded as a question rather than a finding. The reclaim is what
made the number unrecoverable, and knowing that is worth more than
a guess about it.

The failure mode is not always the SIGBUS

A plain nix evaluation reports ENOSPC, which is at least honest.
The SIGBUS this task is named for needs sqlite's mmap. And 4.6 GB
free is one more full suite plus one build: the reclaim buys an
afternoon, not a fix.

How NOT to read the suite result, 2026-09-04

The warnings above push the totals line off the end of the output,
so a reader greps for a failure count instead. This one is wrong:

nix run --file . test -- ... 2>&1 | grep -c 'FAILED'

It reports 0 for a build that never ran the suite at all. A nix
build failure prints error: lines, and the derivation that fails
first is often huggorm-generated, whose own smoke test runs before
the pytest suite exists. Measured here: a change broke
smoke_test.py, that grep answered 0, and the breakage went unseen
for one cycle.

Read the TOTALS line, and drop -q so it survives:

nix run --file . test -- -p no:warnings --tb=line -rf \
  2>&1 | grep -E '^FAILED|passed|failed'

390 passed in 130.41s (0:02:10)

An absent totals line is now the signal it should always have been:
the suite did not run. Which is this repo's named failure mode in the
tooling rather than in the code - a skip that reads as an absence.

The 574 husks are explained, 2026-09-06

LOCK_TIMEOUT = 60 * 60 * 24 * 3 in _pytest/pathlib.py:45. Three
days
, and keep=3 does not apply to a directory whose .lock is
younger than that.

cleanup_candidates yields every numbered directory at or below
max_existing - keep, so an old one IS considered. try_cleanup then
asks ensure_deletable, which returns False while a .lock file
exists and is younger than the timeout (pathlib.py:307-332). No
rename, no garbage-*, no warning - the directory simply stays, and
stays a candidate that is refused on every later run.

A session that exits cleanly unlinks its lock. One that is KILLED
does not. So every pytest killed on this machine leaves a directory
immortal for exactly three days, from every project sharing the root.

Proved on a synthetic root rather than argued, because the real one
cannot be perturbed. Six numbered directories, keep=3:

before: pytest-10 pytest-11 pytest-12 pytest-20 pytest-21 pytest-22
after:            pytest-11           pytest-20 pytest-21 pytest-22

pytest-10 has no lock and goes. pytest-12 has a lock four days
old and goes. pytest-11 has a lock HALF A DAY old and survives,
though it is as far below the window as the other two.

So the growth is bounded after all, at three days rather than at
three runs.

That the 574 were all young-locked is what the mechanism PREDICTS,
not something measured: the evidence was deleted to get the disk
back, which the 2026-09-03 section already records. 574 in a
three-day window implies about 190 killed sessions a day across
every project sharing the root, and nobody counted them. Consistent
with the mechanism, and not a finding.

The one live example, and it is not this suite's either

/tmp/pytest-of-lillecarl/pytest-266   323 MB   .lock from 2026-09-04

Two days old, so it has one more day to live. Its tests are
test_bisect_run, test_workspace_async_concurren0 and
test_short_prefixes_*. None exists in this repository - grepped,
no match. The third time this file has had to say that.

Fixed: this suite gets its own root, 2026-09-06

export PYTEST_DEBUG_TEMPROOT="${PYTEST_DEBUG_TEMPROOT:-/tmp/huggorm}"

in the test runner. pytest's default root is keyed by USER and not
by project, and that one fact caused every confusion in this file:
another project's leftovers counted as this suite's twice, its
unremovable directories warned 177 times on a run here, and
reclaiming meant deleting everybody's.

A FIXED path, not a per-run one. The retention machinery lives under
the basedir, so a fresh root per run would defeat the pruning it
depends on.

The variable only replaces the PARENT. pytest-of-$USER, the
numbering, the locks and the retention all still work. Measured
after the change:

one full run             /tmp/huggorm   562 MB   pytest-0
four more runs           /tmp/huggorm    28 KB   pytest-2 3 4

pytest-0 was pruned by the fourth, which is the retention doing
exactly what it did before. The old root is untouched.

562 MB is this suite's honest per-run cost, measured in isolation
for the first time. Three retained is 1.7 GB steady, on a 61 GB disk.
That answers question 3: acceptable.

No gate, and why not one

The suite runs inside the build sandbox too, where the variable is
unset and the default root is correct. A test asserting the root
would have to SKIP there - and a gate that skips when it breaks is
this repo's named failure mode, so it would be worse than nothing.

The runner prints the root instead:

temp: /tmp/huggorm/pytest-of-lillecarl

One line, on every run, so a run that lost the variable says so.
An invariant nothing can observe is one that gets broken.

Status

DONE. All three questions are answered and the last unexplained
number is explained.

  1. reserved-size - closed 2026-09-01 on a wrong premise. The
    setting is global, not per-store, and no store URI reaches it.
  2. The chmod finalizer - closed 2026-09-01. pytest already does it,
    measured identical with and without.
  3. 562 MB per run, 1.7 GB retained - acceptable, and now measurable
    on its own.

Plus the 574: a three-day lock timeout, not a leak.

What actually filled the disk was never bounded by this suite. It was
one shared root, three days of every project on the machine, and two
immortal directories from an OverlayFS test that does not exist here.

Migrated from tasks/062-the-suite-fills-the-disk.md.done.


Assisted-By: Opus 5

Activity

  1. added
    source: huggorm
    on Oct 19, 2026
  2. transferred this issue fromnixidae/huggormon Oct 19, 2026
  3. added theissue type on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    source: huggorm

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0