Repository navigation
fix: retain parser admission until actual worker completion - #959
Draft
seonghobae wants to merge 1 commit into
Draft
seonghobae wants to merge 1 commit into
seonghobae wants to merge 1 commit into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This branch has not been deployed
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.
Summary
Stacked follow-up to #548 at
dd5ebcfac3f0163fb083741ae834d4f304cb4797.Retain its existing authenticated, non-waiting parser lease until actual
synchronous worker completion after request cancellation. No new queue,
capacity setting, dependency, workflow or authentication policy.
Root cause and repair
Starlette runs the endpoint in a task separate from outer middleware.
Cancelling the outer ASGI request released the lease while its parser thread
continued. The actual ASGI regression observed a second 200 instead of 429.
Store the guarded default-executor completion future in shared request state
before yielding. Defer the existing lease release to exactly one completion
callback. Preserve copied context, temporary uploads, repeated cancellation and
orderly task-shutdown behavior. A completed future can conservatively retain
capacity for one additional loop turn.
Verification
second request remains 429/Retry-After 1/no-store, no extra worker starts,
then capacity recovers with 200 after terminal work.
of all remaining event-loop tasks. Old worker-task implementation failed
shutdown cleanup ordering; guarded executor completion passes.
coverage 100% (893 statements, 264 branches).
found no blocking issue; it did not rerun tests.
Acceptance limits
Draft while parent #548 remains CHANGES_REQUESTED and hosted checks/review are
unaccepted. This is a local authenticated ASGI fixture, not deployment or real
OCR acceptance. Capacity remains per application/process, not global across
replicas or shared model servers. Forced process termination is outside the
cleanup guarantee. Separate native OCR migration continues independently.
Optional wider API-plus-tools coverage was 96.15%, solely in unchanged
tools/benchmark_upload_ingestion.py; it is not claimed as passing. Both hostedrepository test gates explicitly require API-only coverage; no gate was changed.
Durable RCA:
docs/doctoring/parser-cancellation-work-lifetime-20260928.md.