Repository navigation
fix: don't restart a cluster worker twice when ready arrives during stop - #6179
cestercian wants to merge 2 commits into
Conversation
A ready message (or the exit-before-ready path) that lands while a worker is STOPPING was promoted back to online, so the stop's exit was handled as a crash. That scheduled restart_task and the reload/restart path started the worker too, leaving an orphan in the round robin. Fixes Unitech#6178
|
Thanks, the fix is right. I reproduced #6178 with the issue's CLI steps: on The PR fixes two more things:
A few changes before merging:
We'll add the CHANGELOG lines on our side when merging. |
|
Thanks a lot for digging into this and running the full Docker suite. Retargeted to development. I've got the rest done locally (vizion guard, fixture order, fork mode, callback count, the handleExit checks, unit.sh/windows.sh wiring and a slimmer test) and will push it shortly. |
…llback and backoff checks - skip the whole finalizeProcedure/notify block while stopping so vizion_running is never left set - install the SIGINT and message handlers before sending 'booted' - assert the restart callback runs once, cover fork mode, and check that an intentional stop doesn't advance the backoff and that an overlimit app with a backoff ends errored - run the test in unit.sh, note why it's excluded from windows.sh - shared waitFor/holdFor helpers, one driver for the stop cases
|
pushed the review fixes: vizion is guarded while stopping, handlers go in before booted, callback once plus the fork mode and backoff checks, and the unit.sh entry. also cleaned up the test helpers. lmk if anything else needs a tweak |
When a cluster worker sends
ready(or hits the exit-before-ready path) while it's already STOPPING, pm2 flipped it back to online. The stop's exit then got treated like a crash, sorestart_taskkicked in on top of the reload/restart path starting the worker, and you ended up with an orphan worker in the round robin.This keeps a late ready from promoting a stopping worker, so the stop exit is handled as a normal stop.
Tests: added
test/programmatic/issue_6178_late_ready_during_stop.mocha.jswith a fixture that sends ready late during stop, and checks there's only one start and no stray worker.Fixes #6178