What this thread does
Do first: make the side effect idempotent with a durable business-operation key before enabling acks_late=True.
Short answer
As of November 2026, this card targets Celery 5.7.0, released November 5, 2026. Late acknowledgement permits replay after whole-worker loss; it does not supply exactly-once business effects. Mathias Millet’s GitGuardian report, December 5, 2024 describes duplicate risks, OOM interruptions and requeue loops. Millet’s older worker-loss advice differs from the bounded policy in this release; use the versioned configuration contract below.
Choose / don't choose
- One-database effect: choose a unique key and business mutation in one transaction; do not rely on an unlocked read-before-insert.
- Remote effect: choose a provider idempotency key plus durable outcome/reference; a local completion flag alone leaves the remote-success/local-crash gap.
- Unknown remote outcome: reconcile by key/reference before retry; avoid automatic replay when the provider cannot deduplicate or reveal the result (AWS idempotent API design).
Not for: Sidekiq duplicate emails; see sidekiq-retries-sent-duplicate-emails-how-do-i-make-jobs.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
acks_late | True only after idempotency; default early acknowledgement | Celery baseline above | task contract |
task_reject_on_worker_lost | Default False; True allows the message to be re-queued but can loop; not an idempotency fix | Celery baseline above | configuration |
task_retry_on_worker_lost | Use this setting to limit how many times a task is sent again; default False; main worker must survive; overrides rejection with fallback if retry publication fails | Celery baseline above | configuration |
autoretry_for | Tuple of exception classes, e.g. Requests ConnectTimeout; exclude permanent validation/auth failures | Celery baseline above | tasks; Requests exceptions |
retry_backoff / retry_jitter | Choose True / True; backoff default False, jitter default True | Celery baseline above | tasks |
max_retries | Choose finite 5 as an example budget; max_retries = 3; None is unbounded | Celery baseline above | tasks |
retry_backoff_max / default_retry_delay | Backoff cap default 600 seconds; the task is sent again after default_retry_delay (180 seconds by default) | Celery baseline above | tasks; configuration |
Order of operations
1. Derive a business-operation key stable across retries AND duplicate submissions. A broker task ID alone cannot identify independently submitted copies of the same payment. 2. In one database, atomically claim the unique key, mutate business state and store the completed result, then commit. Rollback must undo both claim and mutation. Concurrent duplicate claims must return/reconcile the existing committed outcome (AWS design). 3. For a remote call, durably retain key and request intent first; use the same provider idempotency key each attempt. Persist its outcome/reference after completion. If the process dies after remote success, retry/reconcile with that key; never create a new key to escape the ambiguous outcome. 4. Return only after durable result commit; late acknowledgement follows task completion. Retain attempt time, operation key, provider reference, committed status and broker redelivery/ack evidence to locate the effect-to-ack duplicate window. A result backend SUCCESS alone is not a business uniqueness constraint. 5. On an isolated queue send concurrent duplicates and interrupt after the remote effect but before local completion/ack. Require one effect and the same outcome. Separately exercise whole-worker and child-only death, persistent transient failure and a permanent invalid request; check finite exception retries and terminal disposition.
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
MaxRetriesExceededError | Explicit retry budget exhausted; the current exception may be re-raised when the retry count is exceeded | Record terminal outcome and reconcile the operation; repair the cause before a new authorized attempt | retry contract |
OOM | A task can repeatedly kill its child and be requeued | Fix memory demand; use bounded worker-loss retry policy and monitor broker redeliveries separately | Millet report; configuration |
Missing
- No provider key-retention window or database transaction boundary is specified. Worker-loss retry counts do not cap every broker redelivery. A provider without idempotency or reconciliation requires a manual ambiguity policy.
Checked
2026-11-12; Celery; 5.7.0 release; task/configuration references, Requests API, AWS Builders Library and Mathias Millet report read. No application commands were executed.
Related references: reference 1, reference 2, reference 3.
Started from a post by @Mathias Millet, packaged by the editor. Original post