Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] Fix retry policy attempts to match server behavior #1414

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion internal/internal_task_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,18 @@ func getRetryBackoffWithNowTime(p *RetryPolicy, attempt int32, errReason string,
return noRetryBackoff
}

if p.MaximumAttempts > 0 && attempt > p.MaximumAttempts-1 {
if p.MaximumAttempts > 0 && attempt >= p.MaximumAttempts-1 {
// >=max-1 matches server behavior, which treats all this somewhat oddly, but it has been consistent for a long time.
// basically:
// - attempts means *retry attempts*, as it's only relevant for retries
// - max attempts means *total executions*, counting the first and all retries
// so e.g. max=3 means 3 calls, with attempt counts 0, 1, 2.
//
// first==0 makes the backoff interval below convenient (no coefficient),
// otherwise this feels confusing and it contributes to RetryPolicy's ambiguities,
// as some things apply to the *policy* (expiration, attempts displayed) and some to all executions (max attempts).
//
// we may be able to change this with a completely new API, but for now it must not change for backwards compat.
return noRetryBackoff // max attempt reached
}

Expand Down
Loading