Multiple static Retry-After values throughout the codebase
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- リファクタリング
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- elixir, typescript
- 領域
- api, backend, performance
調査の方向性
まず Electric.AdmissionControl.try_acquire/3 とその過負荷テレメトリから始め、次に lib/electric/plug/serve_shape_plug.ex、lib/electric/shapes/api.ex、lib/electric/shapes/api/params.ex にある列挙された呼び出し箇所を追跡します。それらの現在の Retry-After パスを lib/electric/shapes/api/response.ex と比較します。lib/electric/shapes/api/response.ex は response 層のシリアライザーのままにするべきです。完了とは、一時的なリクエストパスが 1 つのポリシーを使用し、その増加、ジッター、上限、リセット動作がカバーされ、router/API テストが静的な値をアサートしなくなることです。
索引モデルが issue の本文から書いたものです。
説明
Problem
Retry-After is currently calculated in several separate places in packages/sync-service, mostly as fixed values. This makes retry behavior inconsistent and prevents the server from adapting during overload, redeploy, or stack transition events.
This is especially risky because the TypeScript client treats server Retry-After as a floor and combines it with client-side jitter. A fixed server value like 10 can dominate early client backoff attempts and cause many clients to retry together.
Current call sites
lib/electric/plug/serve_shape_plug.ex- DB connection errors set
retry-after: 10directly. - admission-control overload calls a private
calculate_retry_after/2, currently random6..10seconds.
- DB connection errors set
lib/electric/shapes/api.ex- shape creation failure:
retry_after: 1 - stack not ready after timeout:
retry_after: 5 - snapshot creation errors:
retry_after: 10 - long-poll timeout while stack is not up/read-only:
retry_after: 10
- shape creation failure:
lib/electric/shapes/api/params.ex- DB unavailable while validating shape params:
retry_after: 1
- DB unavailable while validating shape params:
lib/electric/shapes/api/response.ex- only serializes the value into the
retry-afterheader and exposes it via CORS; this should likely remain a dumb response-layer concern.
- only serializes the value into the
AdmissionControl already owns the core overload decision, per-stack/per-kind counters, and reject telemetry, but it currently returns only {:error, :overloaded}. The caller then invents the retry delay locally.
Proposal
Centralize Retry-After calculation in logic rooted in Electric.AdmissionControl.
For admission overloads, try_acquire/3 should either return retry metadata, e.g. {:error, {:overloaded, retry_after}}, or expose a central helper that callers use immediately after rejection.
The retry policy should use exponential backoff with jitter, keyed by overload context such as:
stack_id- request kind:
:initialor:existing - reason: admission overload, stack not ready, DB unavailable, snapshot pressure, etc.
Suggested behavior:
- use jitter for every transient
503 - increase delays under sustained rejection/overload
- reset or decay the backoff when capacity recovers
- cap the initial implementation, e.g. at
120s - keep
Cache-Control: no-storeandSurrogate-Control: no-storeon transient overload responses - emit telemetry including
retry_after, reason, kind, current count, limit, and rejection/backoff state
Other transient 503 paths should call the same policy instead of hard-coding 1, 5, or 10.
Acceptance criteria
- No hard-coded sync-service transient
Retry-Aftervalues remain in request handling paths. - Admission-control rejection responses get
Retry-Afterfrom the central policy. - The policy has unit coverage for exponential growth, jitter bounds, cap behavior, and reset/decay.
- Router/API tests assert policy behavior rather than specific static values.
- Docs that mention fixed
Retry-Aftervalues are updated if the public behavior changes.
Open questions
- Should the exponential “attempt” be server-side overload streak state, client-provided attempt metadata, or a hybrid?
- Should DB unavailable, stack not ready, and snapshot pressure share one policy with different baselines, or use separate reason-specific profiles?
- 主要言語
- TypeScript
- スター
- 10.4k
- フォーク
- 399
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
electric-sql/electric のほかの issue
-
camelToSnake and snakeCamelMapper() drop the underscore when a digit precedes a camelCase boundaryオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
electric-sql/electric#4855 ·
-
ShapeStream does not notify subscribers when it gives up on a non-Error value対応中かも @Tyagiquamar が 19 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
electric-sql/electric#4830 ·
-
@electric-sql/client throws SecurityError on import when the browser blocks site storage (typeof localStorage outside try)対応中かも @mohanedmoh が 37 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
electric-sql/electric#4826 · コメント 1 件 ·
-
agents-chat-starter: spawn PUT goes to the durable-streams proxy, so no entity is created and agents never wake対応中かも @adityavkk が 133 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
electric-sql/electric#4687 ·
-
Listen IP addressオープンfeature request triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
electric-sql/electric#4150 · コメント 1 件 ·
electric-sql/electric の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
tintinweb/pi-subagents#459 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
danielmiessler/LifeOS#2830 ·
メンテナーはふだん 6 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
freshframework/fresh#3920 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
area: client enhancement priority: low
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
opensro-dev/opensro#3681 ·
メンテナーはふだん 1 日以内に返信