Skip to content

Preserve worker spawn deadlines in the mold - #233

Merged
rafaelfranca merged 2 commits into
masterfrom
ci-fixes/worker-timeout
Nov 19, 2026
Merged

rafaelfranca merged 2 commits into
masterfrom
ci-fixes/worker-timeout

Conversation

@rafaelfranca

@rafaelfranca rafaelfranca commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Problem

The monitor sets a spawn deadline before it asks the mold to fork.
The mold then creates a Worker and resets the same shared state.
This can clear the deadline, so the monitor can miss a spawn timeout.
The service worker uses the same pattern.
This issue relates to #210.

Solution

Keep the shared state when the mold creates a worker or service worker.
Synchronize the existing timeout test so that it covers this race.

Verification

  • The worker spawn timeout test passed on ARM64 Linux with Ruby 3.3.13.
  • The focused suite passed on x86-64 Linux with Ruby 3.2.3 before the changes were split.
  • CI also reports a parser GC failure that PR Read the body source after destination allocation #231 addresses.
  • A Ruby 4.0 job reported a separate failure in TestInfo#test_close_all_ios_except_marked_ones.

@rafaelfranca

rafaelfranca commented Nov 18, 2026 •

Copy link
Copy Markdown
Member Author

hmmm. This fix the problem, but it is weird fix. The problem was identified correctly, but I feel like having a conditional on the state drop just because it is shared with the model is strange. @byroot what do you think?

I'd instead remove init_state out of initialize and call explicitly, or call the reset! explicitly after the message is handled

@byroot

byroot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Yeah, it all comes down to a design choice inherited from Unicorn, that the Worker class is the same in the parent and children, making things a bit hard to encapsulate.

I agree that no longer automatically calling init_state in initialize is the way to go, that was a mistake.

The monitor sets a spawn deadline before it asks the mold to fork. The mold creates another Worker and resets the same shared state. This can clear the deadline and prevent the monitor from abandoning a slow spawn.

Keep the shared state in the mold. Synchronize the timeout test so that it covers the race.
Worker initialization receives a flag to distinguish the monitor from the mold. The flag spreads process-specific behavior across the worker creation paths.

Attach shared state during initialization, and reset it explicitly when the monitor creates a worker or service. The mold can then attach to the same state without resetting the spawn deadline.
@rafaelfranca
rafaelfranca force-pushed the ci-fixes/worker-timeout branch from 01be78e to 4c366e4 Compare November 19, 2026 16:01
@rafaelfranca
rafaelfranca merged commit 1581be3 into master Nov 19, 2026
13 checks passed
@rafaelfranca
rafaelfranca deleted the ci-fixes/worker-timeout branch November 19, 2026 16:10
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