Skip to content

Handle backoff with new error - #1500

Merged
wild-endeavor merged 4 commits into
mainfrom
handle-queue-cb-backoff
Sep 1, 2026
Merged

Handle backoff with new error#1500
wild-endeavor merged 4 commits into
mainfrom
handle-queue-cb-backoff

Conversation

@wild-endeavor

@wild-endeavor wild-endeavor commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Handle RESOURCE_EXHAUSTED in the remote controller instead of the generic RPC retry interceptor.

  • Introduce ResourceExhaustedError as a specialized SlowDownError.
  • Retry with capped exponential backoff while the controller is running.
  • Track resource-exhaustion attempts separately without incrementing action.retries.
  • Log a warning for each retry.

Why

Resource exhaustion is not a terminal action error and may persist for an arbitrary amount of time. Consuming the normal bounded retry budget would eventually fail runs that should continue waiting.

Testing

  • Added coverage confirming RESOURCE_EXHAUSTED bypasses the generic retry interceptor.
  • Added coverage confirming repeated resource exhaustion does not consume the action retry budget.
  • Tested in staging with:
    • run_concurrency: 1
    • action_concurrency: 2
    • depth: 5
  • Observed retries backing off from 0.5s to 1s, 2s, 4s, and 8s.

Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com>
Comment thread src/flyte/_internal/controllers/remote/_core.py Outdated
Comment thread src/flyte/_internal/controllers/remote/_core.py Outdated
Comment thread src/flyte/_internal/controllers/remote/_core.py Outdated
await informer.fire_completion_event(action.name)

async def _bg_handle_resource_exhausted(self, action: Action, error: ConnectError) -> None:
action.resource_exhausted_retries += 1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we add a max_resource_exhausted_retries?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

or do we want to retry forever?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

my vote is retry forever. upcoming observability should expose long running tasks to the user to manually abort.

from connectrpc.code import Code
from connectrpc.errors import ConnectError

RETRYABLE_CODES = frozenset({Code.UNAVAILABLE, Code.RESOURCE_EXHAUSTED, Code.INTERNAL})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we don't want to use RetryUnaryInterceptor? why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

maybe we do... my reasoning is that unavailable is a network level thing. resource_exhausted we think is not a thing that's sent by nginx/envoy/nlbs, so basically the network request successfully went through - but the server said hold off.

honestly i don't know why we retry on code.internal either - we should not, that would just add to the storm... but i suppose that does give us time to live patch something. we should probably add a sentry on this to see how often we hit this/recover.

Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com>
Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com>
@wild-endeavor wild-endeavor changed the title handle backoff Handle backoff with new error Sep 1, 2026
@wild-endeavor
wild-endeavor marked this pull request as ready for review September 1, 2026 15:42
pingsutw
pingsutw previously approved these changes Sep 1, 2026
Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com>
@wild-endeavor
wild-endeavor merged commit b0bcb4e into main Sep 1, 2026
103 of 104 checks passed
@wild-endeavor
wild-endeavor deleted the handle-queue-cb-backoff branch September 1, 2026 22:44
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.

3 participants