Repository navigation
test: signal the reload child only after it has booted - #56
Merged
Merged
Conversation
This was referenced Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
packages/ruflet/test/run_command_test.rb#test_handle_reload_command_big_r_requests_full_restartwas flaky under load: it failed 3 of 6 runs on unmodifiedmainduring engine test runs, and release verification kept hitting it. The failure is always line 373,assert status.signaled?("R must terminate the child process group").Root cause (test-only)
The test spawned
ruby -e "sleep 30"and sent "R" (TERM to the process group) immediately.Process.spawnreturns afterexec, but the child Ruby is still booting at that point. It installs its signal handlers early and only then loads the gem prelude, RUBYOPT/-rfiles and so on.SignalExceptioninto a plainexit 1.status.signaled?is then false, and the test fails.Under load the parent is descheduled long enough for TERM to hit that window.
Reproduced deterministically by fault injection (
$SP/team/qa-logs/dev-wave3/{slowboot,spawn_delay}.rb). The child's boot is made 0.5 s slower through RUBYOPT, and the test process sleeps 0.2 s afterspawn, imitating being descheduled:The production code is correct. On "R",
run_command.rbsetsrun_state[:restart] = truebefore signalling, and the run loop respawns whenever that flag is set, whatever the child's exit status. A child that exits 1 because R arrived mid-boot is still restarted. So only the test's assumption was wrong.Fix
The test now synchronises on events, with no sleeps and no clocks:
reader.read(2)before sending "R".Process.wait2(child)must show the child died by a signal.IO.select(..., 60)and the children'ssleep 120only bound a broken R, so it fails instead of hanging. Nothing waits on them in the passing path.ensurekills the group only if it wasn't already proven gone, so a reused PID is never targeted.Mutation check: changing R to signal only the child PID (not the group) makes the new test fail with "the grandchild outlived R".
Proof
flutter testloop plus aruflet_coreper-file suite loop ran alongside, with load average 32–43 on 8 cores. The wholerun_command_test.rbunder the same load: 30 runs, 0 failures. Log:flake_proof2.log.flake_proof.log).verify_pr.shwithRUBY_PKGS="ruflet_core ruflet ruflet_server": ruflet_core 145/145 files, ruflet 13/13, ruflet_server 11/11. PASS.Engine: no change.