Skip to content

[Feature] Abort in-flight requests and drain outputs on shutdown#36964

Open
wojciech-wais wants to merge 1 commit intovllm-project:mainfrom
wojciech-wais:feat/shutdown-abort-drain
Open

[Feature] Abort in-flight requests and drain outputs on shutdown#36964
wojciech-wais wants to merge 1 commit intovllm-project:mainfrom
wojciech-wais:feat/shutdown-abort-drain

Conversation

@wojciech-wais
Copy link

@wojciech-wais wojciech-wais commented Mar 13, 2026

When the engine core receives SIGTERM/SIGINT, abort all in-flight requests via the scheduler and send abort outputs to clients before exiting. Then signal the output thread to drain all pending messages (including abort responses) by pushing ENGINE_CORE_DEAD sentinel and joining the thread with a 5s timeout.

Previously, the engine core would exit immediately on signal without notifying clients that their requests were aborted. This left clients hanging with no response. Now clients receive proper abort responses before the process terminates.

Addresses follow-up points from njhill on PR #36666:

  1. Abort requests when shutdown timeout expires
  2. Wait for output thread to drain before exiting

Purpose

Test Plan

Test Result


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

When the engine core receives SIGTERM/SIGINT, abort all in-flight
requests via the scheduler and send abort outputs to clients before
exiting. Then signal the output thread to drain all pending messages
(including abort responses) by pushing ENGINE_CORE_DEAD sentinel and
joining the thread with a 5s timeout.

Previously, the engine core would exit immediately on signal without
notifying clients that their requests were aborted. This left clients
hanging with no response. Now clients receive proper abort responses
before the process terminates.

Addresses follow-up points from njhill on PR vllm-project#36666:
1. Abort requests when shutdown timeout expires
2. Wait for output thread to drain before exiting

Signed-off-by: Wojciech Wais <wojciech.wais@gmail.com>
@wojciech-wais wojciech-wais requested a review from njhill as a code owner March 13, 2026 07:57
@mergify mergify bot added the v1 label Mar 13, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a graceful shutdown mechanism for the engine core. When a SIGTERM or SIGINT is received, it now aborts in-flight requests, sends abort notifications to clients, and waits for the output queue to drain before exiting. This is a valuable improvement that prevents clients from being left in a hanging state. The implementation is clean and includes corresponding unit tests. My main feedback is to make the shutdown timeout configurable to handle various operational environments, which I've detailed in a specific comment.

# Signal the output thread to exit and wait for it to flush
# all pending messages (including the abort outputs above).
self.output_queue.put_nowait(EngineCoreProc.ENGINE_CORE_DEAD)
self.output_thread.join(timeout=5.0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The 5-second timeout for draining the output thread is hardcoded. In scenarios with high load or a slow network, this might not be enough time to send all pending messages, including the abort responses. This could result in some clients not receiving an abort notification, which is the problem this PR aims to solve. This same hardcoded value is also used in _send_engine_dead.

To improve robustness and maintainability, this timeout should be extracted into a constant. A future improvement could be to make this value configurable, for example, via an environment variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant