Dual-path retry: exponential backoff + rate-limit handling#206
Open
MichaelGHSeg wants to merge 2 commits into
Open
Dual-path retry: exponential backoff + rate-limit handling#206MichaelGHSeg wants to merge 2 commits into
MichaelGHSeg wants to merge 2 commits into
Conversation
…dling Replace the fixed 10-attempt retry loop with a structured retry system: - 429 + Retry-After: sleep without consuming retry budget, capped by MaxRateLimitDuration - Other retryable errors: counted exponential backoff (base 500ms, 2x, cap 60s) bounded by MaxRetries and MaxTotalBackoffDuration - Non-retryable status codes (4xx except 408/410/429/460, plus 501/505/511) discard immediately - Remove select on c.quit from retry sleeps so Close() waits for in-flight retries to complete naturally via wg.Wait() - Add X-Retry-Count header on retry attempts - Wire MaxRetries config through to e2e-cli - Enable retry test suite in e2e-config
When io.ReadAll fails on a non-2xx response, wrap the error in httpError with the original status code's retryability instead of returning a raw error (which would be treated as a network error and always retried).
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
Replaces the fixed 10-attempt retry loop with a structured dual-path retry system that separates rate-limiting (429 + Retry-After) from general transient failures.
MaxRateLimitDuration(default 12h).MaxRetries(default 10) andMaxTotalBackoffDuration(default 12h).select { case <-c.quit }from retry sleep paths —Close()now waits for in-flight retries to finish naturally viawg.Wait()instead of killing them mid-flight.X-Retry-Countheader on retry attempts (omitted on first attempt).httpErrorpreserving the original status code's retryability (fixes a bug where a non-retryable 4xx with a broken response body would be incorrectly retried).MaxRetries,MaxTotalBackoffDuration,MaxRateLimitDuration.ErrBackoffBudgetExceeded,ErrRateLimitBudgetExceeded.retrytest suite; wiresmaxRetriesfrom e2e-cli input config.Test plan
go test -race ./...passesbasic,retrysuites pass (48/48)