The Fix
pip install celery==5.1.1
Based on closed celery/celery issue #6793 · PR/commit linked
Production note: This usually shows up under retries/timeouts. Treat it as a side-effect risk until you can verify behavior with a canary + real traffic.
@@ -523,11 +523,12 @@ def on_failure(self, exc_info, send_failed_event=True, return_ok=False):
# is terminated, we aborted it.
# Otherwise, it is revoked.
- if self.message.channel.connection and not self._already_revoked:
+ if self.message.channel.connection:
# This is a special case where the process
import threading
import time
from celery import Celery
app = Celery('celery_revoke_retry', broker='redis://localhost:6379/0', backend='redis://localhost:6379/0')
app.conf.update(worker_concurrency=1)
@app.task
def sleep(sleep_time):
time.sleep(sleep_time)
def main():
argv = ['--app=celery_revoke_retry', 'worker', '--loglevel=DEBUG']
threading.Thread(target=app.worker_main, args=(argv,)).start()
time.sleep(5)
print('Celery should be up now')
r = sleep.s(sleep_time=60).apply_async()
# Note: waiting for the task to start before revoking it will still cause result.state == RETRY
r.revoke(terminate=True)
for _ in range(5):
print(f"State is: {r.state}")
time.sleep(1)
if __name__ == '__main__':
main()
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install celery==5.1.1\nWhen NOT to use: This fix should not be applied if the task's behavior is expected to change upon revocation.\n\n
Why This Fix Works in Production
- Trigger: - [x] I have included all related issues and possible duplicate issues
- Mechanism: The task state incorrectly transitions to RETRY instead of REVOKED when revoked with terminate=True
- Why the fix works: Fix for revoked tasks being moved to RETRY state. (first fixed release: 5.1.1).
- If left unfixed, this can cause silent data inconsistencies that propagate (bad cache entries, incorrect downstream decisions).
Why This Breaks in Prod
- The task state incorrectly transitions to RETRY instead of REVOKED when revoked with terminate=True
- Production symptom (often without a traceback): - [x] I have included all related issues and possible duplicate issues
Proof / Evidence
- GitHub issue: #6793
- Fix PR: https://github.com/celery/celery/pull/6812
- First fixed release: 5.1.1
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.75
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.49
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Hey @djungic :wave:, Thank you for opening an issue”
“The state only becomes RETRY when terminate=True is supplied to revoke. Otherwise the state does not become REVOKED and just stays the same (e.g. PENDING…”
“It does not reproduce in 5.0.5. The example script prints REVOKED, as expected.”
“Seems line 526 here might be the culprit: (https://github.com/celery/celery/commit/934a2271c1636364486eb737a598d224e5184cf8#diff-db65a0e57511553adc360b2e485e25b09e0768b47d76d4e48147ab99994dbbb9R526) Should this be:”
Failure Signature (Search String)
- - [x] I have included all related issues and possible duplicate issues
- or possible duplicates to this issue as requested by the checklist above.
Copy-friendly signature
Failure Signature
-----------------
- [x] I have included all related issues and possible duplicate issues
or possible duplicates to this issue as requested by the checklist above.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
- [x] I have included all related issues and possible duplicate issues
or possible duplicates to this issue as requested by the checklist above.
Minimal Reproduction
import threading
import time
from celery import Celery
app = Celery('celery_revoke_retry', broker='redis://localhost:6379/0', backend='redis://localhost:6379/0')
app.conf.update(worker_concurrency=1)
@app.task
def sleep(sleep_time):
time.sleep(sleep_time)
def main():
argv = ['--app=celery_revoke_retry', 'worker', '--loglevel=DEBUG']
threading.Thread(target=app.worker_main, args=(argv,)).start()
time.sleep(5)
print('Celery should be up now')
r = sleep.s(sleep_time=60).apply_async()
# Note: waiting for the task to start before revoking it will still cause result.state == RETRY
r.revoke(terminate=True)
for _ in range(5):
print(f"State is: {r.state}")
time.sleep(1)
if __name__ == '__main__':
main()
What Broke
Tasks incorrectly transition to RETRY state instead of being marked as REVOKED, causing confusion.
Why It Broke
The task state incorrectly transitions to RETRY instead of REVOKED when revoked with terminate=True
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install celery==5.1.1
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/celery/celery/pull/6812
First fixed release: 5.1.1
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be applied if the task's behavior is expected to change upon revocation.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
- Pin production dependencies and upgrade only with a reproducible test that hits the failing path.
Version Compatibility Table
| Version | Status |
|---|---|
| 5.1.1 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.