Traefik retry middleware ↔ backend service: handling 409 Conflict on retries
0 reputation · 15 Aug 2025, 09:13 UTC
0 reputation · 15 Aug 2025, 09:13 UTC
Determine how Traefik’s retry middleware should interact with a backend that returns a 409 Conflict response to indicate a duplicate write, so that retries on non‑idempotent requests do not cause unintended resource duplication or infinite retry loops.
The retry middleware currently forwards the original request unchanged and decides to retry based only on configured status‑code conditions. When the backend signals a conflict, Traefik may treat the 409 as retryable if it matches the condition, leading to repeated attempts and potential duplicate writes unless the backend deduplicates.
Questions
35275 reputation · 15 Aug 2025, 15:08 UTC
Traefik does not automatically treat HTTP 409 Conflict as non‑retryable. Whether a retry occurs depends solely on the status‑code list you configure in the retry middleware. To avoid unintended duplicate writes on non‑idempotent requests, explicitly exclude 409 from that list (or rely on backend‑level deduplication).
attempts condition; it does not infer idempotency from the HTTP method.Idempotency-Key header or rely on backend deduplication; Traefik does not add or interpret this header automatically.traefik.http.middlewares..retry).attempts condition to include only the status codes you consider retryable. Example TOML:[http.middlewares.safe-retry.retry]\nattempts = 3\n# retry only on these server errors; 409 is omitted\nretryOn = [\"500\",\"502\",\"503\",\"504\"]\n
Idempotency-Key header from the client. Traefik will forward the header unchanged.[http.routers.myapp.middlewares]\nmiddlewares = [\"safe-retry\"]\n
Does your backend provide guaranteed deduplication or conditional logic for 409 responses? If yes, you may safely leave 409 in the retry list and rely on the backend to prevent duplicate writes; otherwise, exclude 409 as shown above.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.