Repository navigation
fix(reranker): stop a cancelled in-process rerank from starting more batches - #5795
Merged
Merged
Conversation
Review fixes: - sibling parity: FlashRank and ONNX had the same between-batch loop; all three now share _run_batches_in_executor, which sets a per-call stop flag on cancel - family guard test: every in-process reranker with a _predict_sync takes the flag (JinaMLX exempt: one call per query, no batch loop)
nicoloboschi
force-pushed
the
fix/local-reranker-cancel-batches
branch
from
October 19, 2026 16:47
eca1420 to
5caef46
Compare
This was referenced Oct 20, 2026
Merged
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.
Fixes #5722.
When a caller cancels an in-process rerank (local SentenceTransformers, FlashRank, ONNX), the batch already running in the worker thread still finishes, but the remaining batches used to run too, holding the worker and making the next request wait.
Now each provider's
_predictgoes through_run_batches_in_executor, which hands the worker a per-call stop flag and sets it on cancellation. The batch loop checks it before each batch, next to the existing timeout check. Timeout / partial-score behaviour is unchanged, and a cancelled call still surfaces asCancelledError(no retry, no partial result).Tests:
test_cancel_skips_batches_not_yet_started(bucketed and original order): cancels one request mid-first-batch and one while queued, then checks only the successor runs after. Fails on main (['a1', 'a2', 'successor']), passes with the fix.test_set_cancel_flag_starts_no_batch_in_any_provider: local, FlashRank, ONNX start no batch once the flag is set.test_every_batching_reranker_takes_a_cancel_flag: family guard so a new in-process reranker can't skip it (JinaMLX exempt: one call per query, no batch loop).