[Bounty $10k] fix(scheduler): add exponential backoff with jitter to queue retries#3931
Open
Karry2019web wants to merge 1 commit into
Open
Conversation
Fixes orchestration-agent#3929 When a task fails in the queue runtime, the TaskScheduler now delays retries with exponential backoff plus random jitter instead of re-enqueuing immediately. This prevents thundering-herd problems where multiple workers retry in lockstep and overwhelm downstream services. Changes: - Add _compute_retry_delay() with exponential backoff + jitter - fail() now schedules retries via schedule() with a computed delay - Add base_retry_delay, max_retry_delay, jitter_factor config params - Add tests for delay scheduling, exponential growth, max retries
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
Fixes #3929
Adds exponential backoff with jitter to
TaskScheduler.fail()so that transient queue failures are retried with increasing delays instead of immediately. This prevents thundering-herd scenarios where multiple retrying tasks overwhelm the queue simultaneously.Changes
_compute_retry_delay(retry_count): New method implementingmin(base * 2^retry, max_delay) * (1 + uniform(-jitter, jitter))fail(): Now callsschedule(delay=...)instead ofenqueue()for retries, inserting a jittered delaybase_retry_delay(1.0s),max_retry_delay(120.0s),jitter_factor(0.5) — all configurable_scheduleddict: Stores retry wakeup times;dequeue()picks them up when expiredTesting
test_fail_respects_max_retries: Verifies retries stop after max retries exhaustedtest_retry_delay_uses_schedule_not_enqueue: Confirms failed tasks go to_scheduledwith future timestampstest_retry_delay_grows_exponentially: Measures delay increases between successive retries