Multiple static Retry-After values throughout the codebase
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Refactorización
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- elixir, typescript
- Área
- api, backend, performance
Línea de trabajo
Empieza con Electric.AdmissionControl.try_acquire/3 y su telemetría de sobrecarga, y después sigue los puntos de llamada indicados en lib/electric/plug/serve_shape_plug.ex, lib/electric/shapes/api.ex y lib/electric/shapes/api/params.ex. Compara sus rutas actuales de Retry-After con lib/electric/shapes/api/response.ex, que debe seguir siendo un serializador de la capa de respuesta. Se considera terminado cuando las rutas de solicitudes transitorias usan una única política, su crecimiento, jitter, límite y comportamiento de reinicio están cubiertos, y las pruebas del router/API ya no comprueban valores estáticos.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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?
- Lenguaje dominante
- TypeScript
- Estrellas
- 10.4k
- Forks
- 399
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de electric-sql/electric
-
camelToSnake and snakeCamelMapper() drop the underscore when a digit precedes a camelCase boundaryAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
electric-sql/electric#4855 ·
-
ShapeStream does not notify subscribers when it gives up on a non-Error valuePosiblemente ocupada @Tyagiquamar la tomó hace 19 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
electric-sql/electric#4830 ·
-
@electric-sql/client throws SecurityError on import when the browser blocks site storage (typeof localStorage outside try)Posiblemente ocupada @mohanedmoh la tomó hace 37 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
electric-sql/electric#4826 · 1 comentario ·
-
agents-chat-starter: spawn PUT goes to the durable-streams proxy, so no entity is created and agents never wakePosiblemente ocupada @adityavkk la tomó hace 133 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
electric-sql/electric#4687 ·
-
Listen IP addressAbiertofeature request triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
electric-sql/electric#4150 · 1 comentario ·
Todos los issues de electric-sql/electric
Issues similares
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
openclaw/openclaw#199885 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
feature needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
BoardGamesEmpire/board-games-empire-backend#1306 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
sequant-io/sequant#1689 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100