Repository navigation
Conversation
shanet
force-pushed
the
fix_accept_after_worker_shutdown
branch
from
September 29, 2026 22:25
b76da9f to
f255f97
Compare
shanet
force-pushed
the
fix_accept_after_worker_shutdown
branch
from
September 29, 2026 22:36
f255f97 to
0a4a376
Compare
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.
Description
My team noticed an issue when a
TERMsignal is sent to shut down a worker, it's possible for that worker to accept & process one more request before shutting down. This is whenqueue_requests falseanddrain_on_shutdown falseare configured.The potential shutdown sequence is:
TERMto its worker. Puma's signal handler writesSTOPto the listener's control pipe.STOPcommand first. ProcessingSTOPafterwards does not prevent B from running.This happens in https://github.com/aha-app/puma/blob/main/lib/puma/server.rb#L402 where if a
TERMsignal is sent while the worker is waiting for capacity inpool.wait_until_not_fullit will accept a subsequent request and process it.A test is included to reproduce this sequence.
The fix here being fairly straightforward: Check again for a stop message after
pool.wait_until_not_fullreturns. This prevents another request from being processed and shuts down the worker immediately.Why this matters: In our case, we are using the shutdown behavior to stop processing requests by a worker in a process address space that we can no longer trust not to leak client data between requests due to errors during processing of the request. Thus, processing even one more request after a
TERMis sent may seem trivial, but is potentially an (unlikely) attack vector that we need to guard against.Your checklist for this pull request
[ci skip]to the title of the PR.#issue" to the PR description or my commit messages.