[Feature Request] Retry an Activity on rate-limit / backpressure errors without consuming MaximumAttempts

オープン
#957 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
8/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
go
領域
testing

調査の方向性

This is a design request that names no files or tests, so there is no concrete entry point yet. Read the two proposed options (per-error-type retry policies versus a flag that skips counting an attempt) and the linked #96 and #463 for context. Done would mean a maintainer-agreed design covering attempt counting, ScheduleToClose bounds, and how the attempt number is reported, not a patch.

索引モデルが issue の本文から書いたものです。

説明

enhancement
Is your feature request related to a problem? Please describe.

Activities that call a rate-limited upstream (HTTP 429, quota exceeded, "slow down" responses) need to retry many times while the upstream is saturated. Today every failed attempt, retryable or not, increments the Activity attempt count and counts toward RetryPolicy.MaximumAttempts. There is no way to say "this failure is backpressure, not a real failure: try again later without penalizing the attempt budget."

ApplicationErrorCategory.BENIGN looks like it should help, but it only changes logging and metrics. A benign failure still counts as an attempt.

The existing workarounds each have a significant drawback:

  1. Retry normally, tuning backoff or NextRetryDelay for 429s. A saturated upstream quickly exhausts MaximumAttempts. That limit was sized for real failures, so you have to choose between failing too early during throttling and allowing far too many retries for genuine errors.
  2. Catch the 429 and sleep or back off inside the Activity. This holds a worker slot for the whole backoff. Work doesn't flow back to the task queue, so there's no real backpressure, and the backoff must fit inside StartToClose and heartbeat timeouts.
  3. Return a non-retryable or typed failure and retry from the Workflow (timer + new Activity). This works, but it re-implements retry orchestration in every Workflow, adds history events, and gives up the server-managed retry policy.
Describe the solution you'd like

A first-class way for a failure to be retried under a separate budget, or without consuming the main attempt budget, so that throttling and real failures are bounded independently. Possible shapes (not mutually exclusive):

Option A: Per-error-type retry policies on the Activity. Let ActivityOptions map an ApplicationFailure type (or category) to its own RetryPolicy, tracked with its own attempt counter. The Activity-level policy remains the catch-all.

ao := workflow.ActivityOptions{
    StartToCloseTimeout: 30 * time.Second,
    RetryPolicy: &temporal.RetryPolicy{MaximumAttempts: 5}, // real failures
    ErrorTypeRetryPolicies: map[string]*temporal.RetryPolicy{
        "RateLimited": {InitialInterval: 2 * time.Second, BackoffCoefficient: 2, MaximumInterval: time.Minute}, // unlimited attempts; bounded by ScheduleToClose
    },
}
message ActivityOptions {
  // existing...
  map<string, temporal.api.common.v1.RetryPolicy> error_type_retry_policies = N;
}

Option B: A failure flag meaning "don't count this attempt." For example, an ApplicationFailure option such as countsTowardMaximumAttempts: false. It could also be implied by a new category such as THROTTLED. The server reschedules the Activity (honoring NextRetryDelay / backoff) without incrementing the attempt counter used for MaximumAttempts. ScheduleToClose still bounds total time, so this cannot retry forever unintentionally.

Either way, the expected behavior is:

  • Throttling failures release the worker slot and return the task to the server/queue, providing real backpressure.
  • NextRetryDelay (e.g. from a Retry-After header) is still honored.
  • Throttling retries do not exhaust the budget meant for genuine failures, and vice versa. In particular, StartToClose timeouts should not consume the throttling allowance.
  • The attempt number seen by the Activity, and visibility/metrics, make it clear which retries were throttling vs. real failures.
Additional context
  • ApplicationErrorCategory.BENIGN already lets users classify expected failures for logging and metrics. Extending classification to retry behavior is a natural next step. The original benign-exceptions design listed per-error-type retry policies as future work.
  • Related: #96 (backoff more on resource-exhausted errors, a client-side analog of the same problem), #463 (customize activity failure logging).
  • This request comes up repeatedly from users running high-throughput Activities against third-party APIs, including LLM providers that enforce rate limits and return Retry-After.
Per-SDK Tickets
  • Server -
  • Go -
  • Java -
  • TypeScript -
  • Python -
  • .NET -
  • Ruby -
  • Rust -
  • PHP -
  • Temporal CLI -
主要言語
Go
スター
35
フォーク
31
平均マージ
1日 12時間
マージ済み PR(30日)
20

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

temporalio/features のほかの issue

temporalio/features の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。