fix: avoid cycle detection in native delayed delivery (#10095)#10112
Conversation
* fix: avoid cycle detection in native delayed delivery
* Avoid RabbitMQ <4.0.1 dead-lettering cycle detection when retrying with native delayed-delivery.
* chore: fix typo, rename, unused variable
---------
Co-authored-by: Asif Saif Uddin {"Auvi":"অভি"} <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v5.6.x #10112 +/- ##
==========================================
- Coverage 88.47% 87.50% -0.97%
==========================================
Files 153 153
Lines 19375 19381 +6
Branches 2228 2229 +1
==========================================
- Hits 17142 16960 -182
- Misses 1934 2125 +191
+ Partials 299 296 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Pull request overview
This PR backports a fix from v5.7 to v5.6.x to address RabbitMQ cycle detection issues when retrying tasks with native delayed delivery. The fix prevents RabbitMQ versions <4.0.1 from detecting dead-lettering cycles by stripping x-death-related headers before republishing tasks during retries.
Changes:
- Added X-Death header filtering in the Context class to prevent RabbitMQ cycle detection issues during task retries
- Added comprehensive unit tests to verify X-Death headers are properly filtered while preserving custom headers
- Added integration tests to verify the fix resolves the RabbitMQ cycle detection issue with quorum queues and native delayed delivery
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| celery/app/task.py | Defines X_DEATH_HEADERS constant and adds _filter_x_death_headers method to Context class, filtering headers in as_execution_options |
| t/unit/tasks/test_tasks.py | Adds unit test verifying X-Death headers are filtered out while preserving custom headers |
| t/integration/test_rabbitmq_quorum_queue_cycle_detection.py | New integration tests reproducing and verifying the fix for RabbitMQ cycle detection with quorum queues |
|
@auvipy thank you so much for this ! |
Description
Backports #10095 to v5.6.x