Skip to content

fix(worker): retry a send cut off by request-timeout before the deadline - #584

Open
dundysm wants to merge 1 commit into
llm-d:mainfrom
dundysm:fix/request-timeout-retry
Open

dundysm wants to merge 1 commit into
llm-d:mainfrom
dundysm:fix/request-timeout-retry

Conversation

@dundysm

@dundysm dundysm commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

a send that request-timeout cuts off while the request's own deadline is still ahead now goes down the retry path instead of ending as a terminal DEADLINE_EXCEEDED result. a request is only finished as DEADLINE_EXCEEDED once its deadline has actually passed.

Why is this change needed?

the worker bounds each send with reqDeadline = min(now + request-timeout, request deadline) (pkg/asyncworker/worker.go), and since #394 any context.DeadlineExceeded on that context is reported as DEADLINE_EXCEEDED:

if errors.Is(reqCtx.Err(), context.DeadlineExceeded) {
	metrics.RecordExceededDeadlineReq(...)
	resultChannel <- asyncapi.NewDeadlineExceededResult(...)

that check cannot tell which of the two bounds fired. with the default request-timeout of 5m, a batch request with a 24h deadline whose attempt hangs for 5m (a stuck replica, a slow gateway queue) is finished as deadline exceeded about 23h55m early, never retried, and counted in the exceeded deadline counter (ExceededDeadlineReqs). the caller gets a result that says its deadline passed when it did not.

the gate path already makes this distinction since #426: a gate-wait timeout is recoverable and "only the request's public deadline" is terminal (requestDeadlineReached). and a timeout raised inside the http client is already retried, because transportErrorCategory classifies Timeout() errors as ErrCategoryServer. the send-context timeout was the one case left that skipped both.

with this change the check is errors.Is(reqCtx.Err(), context.DeadlineExceeded) && requestDeadlineReached(msg.PublicRequest, time.Now()). when the deadline is the bound that fired, behaviour is unchanged (TestDeadlineAbortedSendClassifiedAsDeadlineExceeded still passes). when request-timeout fired first, the error is the client's ErrCategoryServer transport timeout, so retryMessage re-enqueues it with backoff, and if the deadline is spent by then it still emits DEADLINE_EXCEEDED from there.

one tradeoff worth calling out: a generation that legitimately runs longer than request-timeout is now retried until its deadline instead of failing after the first attempt. that matches what request-timeout is documented as (a per-request inference timeout, not a lifetime), and such deployments already needed a larger request-timeout to get any result. if you would rather keep a timed-out attempt terminal, the alternative is to keep it fatal but report it as an inference error instead of DEADLINE_EXCEEDED; happy to switch to that.

How was this tested?

  • Unit tests added/updated
  • Integration/e2e tests added/updated
  • Manual testing performed

TestRequestTimeout asserted the old terminal outcome (its comment says the timeout error is ErrCategoryUnknown, which stopped being true when transportErrorCategory landed). it now runs a 100ms request-timeout against a request 100s from its deadline and checks the message is re-enqueued with RetryCount 1 and a positive backoff, the client was called once, and the exceeded deadline counter did not move. on main it fails:

--- FAIL: TestRequestTimeout (0.10s)
    worker_test.go:845: a request-timeout abort with the deadline 100s away must be retried, got terminal result code "DEADLINE_EXCEEDED" (message "deadline exceeded")
    worker_test.go:853: exceeded deadline counter moved from 0 to 1 before the request's deadline

with the fix go test ./pkg/... ./pipeline/... ./api/... passes, and go vet ./pkg/asyncworker/ and gofmt are clean, and hack/lint-release-notes.sh passes on the fragment in release-notes.d/unreleased/584.md. i did not run the e2e suite (needs a cluster).

docs/deployment.md now says request-timeout bounds one attempt and that only the deadline ends a request as DEADLINE_EXCEEDED.

Checklist

  • Commits are signed off (git commit -s) per DCO
  • Code follows project contributing guidelines
  • Tests pass locally (make test) (ran go test ./pkg/... ./pipeline/... ./api/... instead)
  • Linters pass (make lint)
  • Documentation updated (if applicable)

Related Issues

related to #394, #426, #103

Release note

a send cut off by request-timeout while the request's deadline is still ahead is now retried instead of ending as DEADLINE_EXCEEDED.

@github-actions

Copy link
Copy Markdown

Unsigned commits detected! Please sign your commits.

For instructions on how to set up GPG/SSH signing and verify your commits, please see GitHub Documentation.

request-timeout bounds one inference attempt, but the send context is
min(now + request-timeout, request deadline), and any DeadlineExceeded on
it was reported as a terminal DEADLINE_EXCEEDED result. a request with a
24h deadline whose attempt hit the 5m default timeout was finished as
deadline exceeded 23h55m early, and counted in the exceeded deadline
metric.

only finish the request as DEADLINE_EXCEEDED when its own deadline has
passed. otherwise the attempt goes down the retry path like any other
transport timeout, the same way a gate-wait timeout is already
recoverable.

Signed-off-by: Dundy Pasupuleti <dundysm@gmail.com>
@dundysm
dundysm force-pushed the fix/request-timeout-retry branch from 38168e6 to 37bcfcf Compare November 24, 2026 13:13
@dundysm

dundysm commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@shimib could you take a look when you have a moment? the send path still turns a request-timeout abort into a terminal DEADLINE_EXCEEDED even when the request deadline is hours away, unlike the gate-wait timeout from #426. i noted an alternative in the description if you would rather keep a timed-out attempt terminal.

@shimib

shimib commented Nov 24, 2026

Copy link
Copy Markdown
Member

Thanks for this. Before it can be reviewed for merge, the commit needs a verified signature: the signed-commits check is failing on 37bcfcf (the DCO sign-off is fine, this is the GPG/SSH signature).

Could you sign the commit and force-push? git commit --amend -S --no-edit followed by a force-push does it once a signing key is set up and registered on GitHub as a signing key. GitHub's guide is here.

@shimib

shimib commented Nov 28, 2026

Copy link
Copy Markdown
Member

I'd keep the retry, not the terminal alternative. It matches the gate path (#426) and the transform path, which since #587 retries an attempt cut off by request-timeout and cites this PR. I merged the branch onto current main: it merges cleanly, go test -race ./pkg/asyncworker/ passes, and TestRequestTimeout fails without the worker.go change.

Two requests:

  • The commit still needs a verified signature (signed-commits fails on 37bcfcf).
  • In docs/deployment.md, say what the trade-off costs: a generation that needs longer than request-timeout never completes. It is retried until its deadline and holds a slot for the full timeout on each attempt, about 250 attempts over a 24h deadline with the 5m default. Operators should set request-timeout above the longest generation they expect.

Not for this PR: after such a run the final result is a bare DEADLINE_EXCEEDED. #586 tracks carrying the last error.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants