Skip to content

fix: Ensemble requests stuck indefinitely when the step max_queue_size exceeded - #466

Merged
pskiran1 merged 7 commits into
mainfrom
spolisetty/tri-654-bug-in-ensemble-scheduler-when-using-dynamic-batcher
Feb 11, 2026
Merged

fix: Ensemble requests stuck indefinitely when the step max_queue_size exceeded#466
pskiran1 merged 7 commits into
mainfrom
spolisetty/tri-654-bug-in-ensemble-scheduler-when-using-dynamic-batcher

Conversation

@pskiran1

@pskiran1 pskiran1 commented Feb 2, 2026

Copy link
Copy Markdown
Member

This PR addresses a critical issue where ensemble requests could hang indefinitely when the step max_queue_size limits were exceeded. The fix ensures proper error handling and cleanup by allowing completed steps to be consumed even after errors occur, preventing in-flight counter deadlocks.

Changes:

  • Modified PrepareSteps to always process completed steps for proper cleanup, even when the ensemble has failed
  • Added error_response_sent_ flag to prevent duplicate error responses
  • Enhanced error handling to preserve original error status while still cleaning up in-flight steps

CI: triton-inference-server/server#8631

Background:
max_queue_size worked correctly, and the request was properly rejected with an error status. However, the ensemble scheduler had a critical bug that prevented proper cleanup after rejection, causing the hang. When ensemble_status_ was updated to unhealthy, UpdateEnsembleState() calls were skipped, and responses were not consumed, so inflight_step_counter_ never reached zero, and the request remained stuck indefinitely.

https://github.com/triton-inference-server/core/pull/466/changes#diff-ce8a574cf83a8bc8293e1be3573c9fb2d84cc681a8f6c6a66503bd844570934eR969

https://github.com/triton-inference-server/core/pull/466/changes#diff-ce8a574cf83a8bc8293e1be3573c9fb2d84cc681a8f6c6a66503bd844570934eR1338

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a critical issue where ensemble requests could hang indefinitely when step max_queue_size limits were exceeded. The fix ensures proper error handling and cleanup by allowing completed steps to be consumed even after errors occur, preventing inflight counter deadlocks.

Changes:

  • Modified PrepareSteps to always process completed steps for proper cleanup, even when ensemble has failed
  • Added error_response_sent_ flag to prevent duplicate error responses
  • Enhanced error handling to preserve original error status while still cleaning up in-flight steps

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ensemble_scheduler/ensemble_scheduler.cc Outdated
Comment thread src/ensemble_scheduler/ensemble_scheduler.cc Outdated
Comment thread src/ensemble_scheduler/ensemble_scheduler.cc Outdated
pskiran1 and others added 4 commits February 2, 2026 11:32
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@whoisj whoisj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am slightly confused here. Does this fix the problem or just turn full queues into error conditions?

Comment thread src/ensemble_scheduler/ensemble_scheduler.cc
@yinggeh

yinggeh commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

Test case?

@pskiran1

pskiran1 commented Feb 3, 2026

Copy link
Copy Markdown
Member Author

Test case?

Please refer to PR triton-inference-server/server#8631

whoisj
whoisj previously approved these changes Feb 3, 2026
@yinggeh

yinggeh commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

How could max_queue_size be exceeded?

@pskiran1

pskiran1 commented Feb 4, 2026

Copy link
Copy Markdown
Member Author

How could max_queue_size be exceeded?

We can exceed the max_queue_size of a step if we create a situation where more requests are queued at that step than it can handle.
I reproduced this with a similar test triton-inference-server/server#8631: the first step is a decoupled model that produces many requests and has a short processing delay, while the second step is slower and configured with max_queue_size = 4.
When we send an inference request, step 1 quickly generates more requests than step 2 can consume in time. As a result, the intermediate requests queued for step 2 exceed the configured limit. Our changes ensure that, in this case, the excess requests are rejected gracefully instead of causing the system to hang.

@yinggeh

yinggeh commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

max_queue_size

Why did it hang before instead of rejecting the request (which line)? Did max_queue_size completely not work at all before?

@whoisj

whoisj commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

max_queue_size

Why did it hang before instead of rejecting the request (which line)? Did max_queue_size completely not work at all before?

Very good question and something I would think we should be concerned more about.

@pskiran1

pskiran1 commented Feb 5, 2026

Copy link
Copy Markdown
Member Author

max_queue_size

Why did it hang before instead of rejecting the request (which line)? Did max_queue_size completely not work at all before?

max_queue_size worked correctly, and the request was properly rejected with an error status. However, the ensemble scheduler had a critical bug that prevented proper cleanup after rejection, causing the hang. When ensemble_status_ was updated to unhealthy, UpdateEnsembleState() calls were skipped, and responses were not consumed, so inflight_step_counter_ never reached zero, and the request remained stuck indefinitely.

https://github.com/triton-inference-server/core/pull/466/changes#diff-ce8a574cf83a8bc8293e1be3573c9fb2d84cc681a8f6c6a66503bd844570934eR969

https://github.com/triton-inference-server/core/pull/466/changes#diff-ce8a574cf83a8bc8293e1be3573c9fb2d84cc681a8f6c6a66503bd844570934eR1338

@yinggeh

yinggeh commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

max_queue_size

Why did it hang before instead of rejecting the request (which line)? Did max_queue_size completely not work at all before?

max_queue_size worked correctly, and the request was properly rejected with an error status. However, the ensemble scheduler had a critical bug that prevented proper cleanup after rejection, causing the hang. When ensemble_status_ was updated to unhealthy, UpdateEnsembleState() calls were skipped, and responses were not consumed, so inflight_step_counter_ never reached zero, and the request remained stuck indefinitely.

https://github.com/triton-inference-server/core/pull/466/changes#diff-ce8a574cf83a8bc8293e1be3573c9fb2d84cc681a8f6c6a66503bd844570934eR969

https://github.com/triton-inference-server/core/pull/466/changes#diff-ce8a574cf83a8bc8293e1be3573c9fb2d84cc681a8f6c6a66503bd844570934eR1338

Should add that to the PR description.

Comment thread src/ensemble_scheduler/ensemble_scheduler.cc
Comment thread src/ensemble_scheduler/ensemble_scheduler.cc Outdated
yinggeh
yinggeh previously approved these changes Feb 9, 2026

@yinggeh yinggeh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Left some comments. LGTM in general

@pskiran1
pskiran1 dismissed stale reviews from yinggeh and whoisj via 43bd014 February 10, 2026 12:04
…into spolisetty/tri-654-bug-in-ensemble-scheduler-when-using-dynamic-batcher
@pskiran1
pskiran1 requested a review from yinggeh February 10, 2026 12:33

@yinggeh yinggeh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice work!

@pskiran1
pskiran1 merged commit 5280db8 into main Feb 11, 2026
1 check passed
@pskiran1
pskiran1 deleted the spolisetty/tri-654-bug-in-ensemble-scheduler-when-using-dynamic-batcher branch February 11, 2026 17:37
mc-nv pushed a commit that referenced this pull request Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: fix A bug fix

Development

Successfully merging this pull request may close these issues.

4 participants