Multiple static Retry-After values throughout the codebase
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- elixir, typescript
- Lĩnh vực
- api, backend, performance
Hướng nghiên cứu
Bắt đầu với Electric.AdmissionControl.try_acquire/3 và telemetry về tình trạng quá tải của nó, sau đó lần theo các call site được liệt kê trong lib/electric/plug/serve_shape_plug.ex, lib/electric/shapes/api.ex và lib/electric/shapes/api/params.ex. So sánh các đường đi Retry-After hiện tại của chúng với lib/electric/shapes/api/response.ex, vốn nên tiếp tục là serializer của response layer. Hoàn thành có nghĩa là các đường đi của request tạm thời sử dụng một policy duy nhất, mức tăng, jitter, cap và hành vi reset của policy đó được bao phủ, đồng thời các test của router/API không còn assert các giá trị tĩnh.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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?
- Ngôn ngữ chính
- TypeScript
- Star
- 10.4k
- Fork
- 399
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của electric-sql/electric
-
camelToSnake and snakeCamelMapper() drop the underscore when a digit precedes a camelCase boundaryĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
electric-sql/electric#4855 ·
-
ShapeStream does not notify subscribers when it gives up on a non-Error valueCó thể đã có người làm @Tyagiquamar đã nhận 19 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
electric-sql/electric#4830 ·
-
@electric-sql/client throws SecurityError on import when the browser blocks site storage (typeof localStorage outside try)Có thể đã có người làm @mohanedmoh đã nhận 37 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
electric-sql/electric#4826 · 1 bình luận ·
-
agents-chat-starter: spawn PUT goes to the durable-streams proxy, so no entity is created and agents never wakeCó thể đã có người làm @adityavkk đã nhận 133 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
electric-sql/electric#4687 ·
-
Listen IP addressĐang mởfeature request triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
electric-sql/electric#4150 · 1 bình luận ·
Tất cả issue của electric-sql/electric
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
tintinweb/pi-subagents#459 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
danielmiessler/LifeOS#2830 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
freshframework/fresh#3920 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area: client enhancement priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
opensro-dev/opensro#3681 ·
Maintainer thường phản hồi trong vòng 1 ngày