Skip to content

stop the two builds of a case deleting each other's files - #5

Merged
tamnd merged 1 commit into
mainfrom
tempdir-race
Aug 22, 2026
Merged

tamnd merged 1 commit into
mainfrom
tempdir-race

Conversation

@tamnd

@tamnd tamnd commented Aug 22, 2026

Copy link
Copy Markdown
Owner

The suite is flaky under ctest -j and has been. This is why.

Every file here is built twice, once at C++23 and once at the C++20 floor, so test_bulk and test_bulk_cxx20 are the same cases in two processes and under -j they run at the same moment. TempDir named its directory after the case and a counter that restarts in each process, then called remove_all on that name before creating it. Both processes asked for zu-cpp-append-6, and whichever got there second deleted the first one's database in the middle of a bulk load.

The failures that came back said io: /tmp/zu-cpp-append-6/people.zu: No such file or directory on a path the case had written a line earlier. That reads like an engine bug, and it is not one. It moved between files from run to run, which is the worst shape a failure can have: a suite that fails somewhere different each time is a suite people stop reading.

The fix is to find a free name by making it rather than by picking one and clearing whatever is there. create_directory is a single mkdir, so of two processes asking for the same name at the same instant exactly one is told it created it and the other moves to the next number. Nothing in here removes a directory it did not create, which is the property that was missing.

Verified on Linux with gcc 13 against libzu from engine HEAD: three consecutive ctest -j 16 runs, 35 of 35 green each time. Before this, the same command failed between two and eleven cases per run.

Every file in this suite is built twice, at C++23 and at the C++20
floor, so under ctest -j two processes run the same cases at the same
moment. The temp directory helper named its directory after the case and
a counter that restarts in each process, and then cleared whatever was
already at that name, so both processes asked for zu-cpp-append-6 and
the second one deleted the first one's database halfway through a load.

What came back was "no such file or directory" on a path the case had
written a line earlier, which reads like an engine bug and is not one.
It was intermittent and it moved around, and a flaky suite is a suite
people stop reading.

The name is now found by making it rather than by picking one and
clearing it. create_directory is a single mkdir, so of two processes
asking for the same name exactly one is told it made it and the other
tries the next number. Nothing removes a directory it did not create.
@tamnd
tamnd merged commit fa34cb8 into main Aug 22, 2026
5 checks passed
@tamnd
tamnd deleted the tempdir-race branch August 22, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant