Skip to content

Default RetryPolicy max_retry_interval and prevent capped backoff overflow - #370

Open
andystaples wants to merge 5 commits into
mainfrom
andystaples-retry-policy-default-max-interval
Open

andystaples wants to merge 5 commits into
mainfrom
andystaples-retry-policy-default-max-interval

Conversation

@andystaples

@andystaples andystaples commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #367

Summary

  • Overflow fix: RetryableTask.compute_next_delay() evaluated math.pow(coefficient, attempt - 1) before applying max_retry_interval, so a capped policy could still fail the orchestration with OverflowError once the unused power overflowed. An overflowing power now saturates and the configured cap applies.
  • New default: RetryPolicy.max_retry_interval now defaults to one hour or first_retry_interval, whichever is longer, instead of unbounded. Passing max_retry_interval=None explicitly keeps uncapped delays. Taking the longer of the two means a policy with a long constant interval (for example, 6-hour retries) is never shortened by the new default.

Cross-SDK alignment

SDK Default max retry interval Overflow handling
durabletask-dotnet 1 hour Math.Pow → Infinity, compared against cap
durabletask-js 1 hour Math.pow → Infinity, Math.min caps
durabletask-java none catches ArithmeticException, returns cap
durabletask-go none caps before converting

.NET silently caps a first interval longer than one hour, and JS rejects such policies at construction. This PR instead never shortens the configured first interval.

Compatibility

Changing the default can affect in-flight retries whose policy omits max_retry_interval and whose next delay already exceeds the new cap:

  • Already-scheduled retry timers keep their recorded fire time; later attempts use the new cap.
  • Retry delays longer than the worker's maximum_timer_interval (three days by default on TaskHubGrpcWorker and the Functions worker) are split into multiple timers. When the capped delay needs fewer parts than were recorded, the retry runs early after its last part fires, or replay fails with NonDeterminismError if an extra part was already recorded.
  • DurableTaskSchedulerWorker never splits timers, so it is not exposed to the NonDeterminismError case. Functions apps split timers regardless of storage backend, including when using Durable Task Scheduler.

The changelogs call this out and recommend draining affected instances, or setting max_retry_interval=None on those policies before upgrading.

Histories that previously ended with the OverflowError are terminal failures, so the overflow fix has no in-flight replay impact.

Release coordination

The Azure Managed and Functions changelogs describe the behavior with the corresponding core update; version and dependency minimum bumps belong in the release PR.

…rflow

RetryPolicy.max_retry_interval now defaults to one hour or
first_retry_interval, whichever is longer; passing None keeps uncapped
delays. Backoff calculations that overflow now saturate at the configured
cap instead of failing the orchestration with OverflowError.

Fixes #367

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 18:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Replay compatibility after the retry-cap default change remains untested, and the upgrade warning overstates which recorded timer histories will fail.

2 open issues
What changed in this PR

Addresses #367 by preventing capped retry backoff from failing on power overflow and introducing a bounded default for retry delays in the core SDK.

Changes:

  • Defaults max_retry_interval to one hour or the first retry interval, whichever is longer; explicit None remains uncapped.
  • Handles exponential-backoff overflow and adds focused regression tests.
  • Documents the new default, replay risks, and upgrade guidance across all three packages.
File Description
tests/​durabletask/​test_retry_backoff.py Tests default caps, uncapped delays, and overflow handling.
durabletask/​task.py Implements the default cap and overflow handling.
durabletask-azuremanaged/​CHANGELOG.md Documents Managed provider behavior and upgrade implications.
docs/​features.md Explains the retry cap default and opt-out.
CHANGELOG.md Records core behavior changes and replay warnings.
azure-functions-durable/​CHANGELOG.md Documents Functions provider behavior and replay risks.

Review effort: Balanced

Comment thread durabletask/task.py Resolved
Comment thread CHANGELOG.md Resolved
andystaples and others added 4 commits November 23, 2026 12:43
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…-max-interval' into andystaples-retry-policy-default-max-interval

# Conflicts:
#	CHANGELOG.md
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

RetryPolicy max_retry_interval does not prevent backoff overflow, failing capped retries

2 participants