Skip to content

Replace the latest link atomically - #479

Merged
samoht merged 2 commits into
mirage:mainfrom
samoht:fix-latest-race
Nov 12, 2026
Merged

samoht merged 2 commits into
mirage:mainfrom
samoht:fix-latest-race

Conversation

@samoht

@samoht samoht commented Nov 10, 2026

Copy link
Copy Markdown
Member

Every test executable of a package logs to the same _build/_tests, and dune runs them in parallel. Each run removed latest and then created it again, so concurrent runs kept removing each other's link and one gave up after six EEXIST in a row. This is the macOS failure on ocaml/opam-repository#31135:

exception Failure("Failed 6 times to create symlink .../_build/_tests/run/locale/20261110-145014-GWB2CVSF (Unix.EEXIST)")

The link is now created under a name unique to the run and renamed over latest, which is atomic. test_latest_race runs 32 processes of 100 runs each on one log directory: it failed 10 times out of 10 before this change and 0 out of 10 after.

The link also pointed to root/run/..., relative to the folder of the link itself, so it was dangling whenever the log directory was a relative path. It now points to run/....

@samoht
samoht force-pushed the fix-latest-race branch 2 times, most recently from 72d5c87 to 7d9584f Compare November 11, 2026 15:12
@samoht samoht mentioned this pull request Nov 11, 2026
Every test executable of a package logs to the same _build/_tests, and
dune runs them in parallel. Each run removed `latest` and then created
it again, so concurrent runs kept removing each other's link and one
gave up after six EEXIST in a row, failing the test:

  Failed 6 times to create symlink .../_build/_tests/run/locale/... (Unix.EEXIST)

The link is now created under a name unique to the run and renamed over
`latest`, which is atomic. test_latest_race runs 32 processes of 100
runs each on one log directory: it failed 10 times out of 10 before
this change and 0 out of 10 after.

The link also pointed to root/run/..., relative to the folder of the
link itself, so it was dangling whenever the log directory was a
relative path. It now points to run/....
@samoht
samoht merged commit b1134e7 into mirage:main Nov 12, 2026
7 checks passed
@samoht
samoht deleted the fix-latest-race branch November 12, 2026 11:02
jmid pushed a commit to ocaml/opam-repository that referenced this pull request Nov 17, 2026
CHANGES:

- Fix parallel test runs failing with `Failed 6 times to create symlink`, and
  a dangling `latest` link (mirage/alcotest#479, @samoht, fixes mirage/alcotest#471 and mirage/alcotest#472 in 1.10.0)
- Fix tests failing with `EACCES` on a read-only source tree or with
  `DUNE_BUILD_DIR` (mirage/alcotest#480, @samoht, fixes mirage/alcotest#471 in 1.10.0)
- Honour `ALCOTEST_SOURCE_CODE_POSITION` when set by the program before `run`
  (mirage/alcotest#481, @samoht, fixes mirage/alcotest#451 in 1.10.0)
- Fix slow runs of suites with many cases of the same name (mirage/alcotest#482, @samoht,
  fixes mirage/alcotest#451 in 1.10.0)
- Under Eio, point the failure locations added in 1.10.0 (mirage/alcotest#451) at the test,
  not at the scheduler (mirage/alcotest#484, fixes mirage/alcotest#478, @samoht, report by @talex5)
- Point a failed `check` in a helper at the `check`, as in 1.9.1, not at the
  test that calls the helper (mirage/alcotest#488, @samoht, fixes mirage/alcotest#451 in 1.10.0)
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