← Back to Pull requests

fix(core): release request IDs when their tracked tasks finish #6092

Open
unknown opened this pull request with 548 lines diff across 6 files
View on GitHub
unknown unknown commented on Nov 12, 2026 04:30 UTC
Author

What happens

A completed task can remain in CancelMixin._running_tasks while another
object, such as a rejected retry's exception traceback, retains it. Reusing
the ID then keeps raising an error after the tracked request or abort block
has finished.

The regression tests retain completed tasks explicitly. Any extra delay in
a live server depends on object lifetimes and garbage collection; there is
no fixed extension to the abort-block duration.

| Tracked task | Before | After |
| --- | --- | --- |
| Pending request task | Duplicate rejected | Duplicate rejected |
| Running abort-block task | Retry rejected | Retry rejected |
| Retained completed request task | Duplicate rejected | Admission allowed |
| Retained completed abort-block task | Retry rejected | Admission allowed |

The existing contract in doc/source/user_guide/client_api.rst is:

IDs must be unique among active requests on a replica. After an abort, the ID is blocked for 30 seconds by default; use a fresh ID for retries, or configure `block_duration in the abort request.

Cause

CancelMixin._add_running_task treats every surviving WeakValueDictionary
entry as active, even when its task is done.

Change

Check Task.done() before rejecting admission. The existing assignment
replaces a completed entry with the current task.

Pending tasks still reserve their IDs, including tasks processing
cancellation. Abort blocks still reject admission while their tasks are
running. This brings admission into line with the documented contract.

Tests

The new regression is parametrized over a completed ordinary request and
an expired abort block. Both cases retain the completed task and verify
that registration replaces it with the current task. The neighboring test
continues to reject active duplicates and unexpired abort blocks under
native and shared scheduling.

Recorded contributor validation compares fa9cd800 with base 4bd087a9.

Linux validation on Ubuntu 24.04.5 LTS:

| Run | Result |
| --- | --- |
|
xinference/core/tests/test_request_priority.py, Python 3.12.3, Transformers 5.22.2 as recorded in the environment header | 55 passed |
| Same module, Python 3.12.3, Transformers 4.57.6 | 55 passed |
| Same module, Python 3.10.22 | 55 passed |
| Four consumer modules below, Python 3.12.3 | 137 passed |

xinference/api/tests/test_cache_salt.py
xinference/core/tests/test_launch_strategy.py
xinference/core/tests/test_list_models.py
xinference/model/image/ocr/tests/test_ocr_engine_resolution.py

Restoring production files from 4bd087a9 while retaining the new tests
produces the expected failing run, with exit status 1.

Windows contributor runs on Python 3.10.20 and 3.14.6, using Transformers
5.17.0 and xoscar 0.11.2, give 2 failed and 53 passed on the base, then
55 passed with the fix on each version. The two base failures are
Duplicate request id: reusable-id and
The request has been aborted: reusable-id. These are supplemental runs;
their xoscar version is below the project's declared minimum.

The following adjacent modules were also run on both Windows versions:

xinference/core/tests/test_model_generation.py
xinference/core/tests/test_pd_model.py
xinference/core/tests/test_realtime_data_plane.py
xinference/api/tests/test_llm_request_abort.py
xinference/api/tests/test_non_streaming_request_abort.py
xinference/api/tests/test_anthropic_request_abort.py
xinference/api/tests/test_ocr_response_contract.py
xinference/api/tests/test_sdapi_routes.py
xinference/model/image/tests/test_mineru25_integration.py
xinference/model/llm/trt_llm/tests/test_core.py

Each initial run gives 436 passed, 5 failed and 3 setup errors. The three
setup-error cases pass when rerun with a writable pytest temporary
directory. All five remaining failures reproduce on
4bd087a9: one Unix
PATH-separator expectation and four cases requiring the absent
websockets package.

Linux pre-commit checks pass, including Black 25.1.0, Ruff 0.15.22,
isort 5.12.0, mypy 1.15.0 and codespell 2.2.2. The checked scope includes
the changed files and
xinference/types.py. Test-platform coverage and
git diff --check` also pass.

AI disclosure: this was prepared with AI assistance (Claude Opus 5.5 and Claude Sonnet 5.5).

🤖 Generated with Claude Code

https://claude.ai/code/session_01JfvcPZyKcKQUG9fQGYfRMw

Diff: 548 lines (+411 / -137) across 6 files Reviewer: Jackmeson1 Review duration: 780m
All Vouch review confidence checks passed
Residual risk 0.27 = Change Risk (0.48) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 548 lines diff across 6 files
0.48
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
42%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.377
Shallow Review Depth shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #6092"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 43.0% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 48.1% (MEDIUM) · Higher = larger blast radius
48.1%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 43.0% · Lower = rushed or shallow review
43.0%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 27.4% · Safe to merge
27.4%