Skip to content

Fix race in OrderReporterTest#test_forking - #426

Merged
markdorison merged 1 commit into
mainfrom
fix-order-reporter-forking-race
Sep 18, 2026
Merged

markdorison merged 1 commit into
mainfrom
fix-order-reporter-forking-race

Conversation

@markdorison

Copy link
Copy Markdown
Contributor

start truncates the log. test_forking forked start and the five before_test writers concurrently and only waited at the end, so the truncate could land after an append and erase it. Seen on main at 7074624: ruby-tests (4.0, ~> 5.11) got 4 of 5 lines back (run) while two other runs of the same SHA passed.

  • Wait for the start fork before spawning writers. Matches production ordering (parent calls start, then workers fork) and keeps the lazy per-worker File.open path under test.
  • Drop delete_log: never called, and File.exists? was removed in Ruby 3.2.

Verified on Ruby 4.0.7: with a 10ms delay injected into start, the old test fails (+[], all lines lost) and the fixed test passes. Fixed file passes 10 of 10 runs.

`start` truncates the log file. The test forked `start` and the five
`before_test` writers concurrently and only waited on all of them at the
end, so the truncate could land after one or more appends and erase them.
Seen on main (7074624): ruby-tests (4.0, ~> 5.11) got 4/5 lines back
while two other runs of the same SHA passed.

Wait for the `start` fork before spawning the writers. This matches
production ordering (parent calls `start`, then workers fork) while still
exercising the lazy per-worker `File.open` path the test exists for.

Also drop `delete_log`: never called, and `File.exists?` was removed in
Ruby 3.2.

Assisted-By: devx/5182f76b-a2d3-465f-8030-398a21f6a485
@markdorison markdorison self-assigned this Sep 18, 2026
@markdorison
markdorison marked this pull request as ready for review September 18, 2026 20:01
@markdorison
markdorison merged commit 88ddd0e into main Sep 18, 2026
34 checks passed
@markdorison
markdorison deleted the fix-order-reporter-forking-race branch September 18, 2026 20:38
@mdwn mdwn mentioned this pull request Sep 30, 2026

This branch was successfully deployed

1 active deployment
rubygems — 940272b6 Deployed Sep 18, 2026 by shopify-shipit[bot]
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.

2 participants