Skip to content

Native Delayed Delivery in RabbitMQ#9207

Merged
Nusnus merged 48 commits intocelery:mainfrom
Katz-Consulting-Group:blm-375
Nov 17, 2024
Merged

Native Delayed Delivery in RabbitMQ#9207
Nusnus merged 48 commits intocelery:mainfrom
Katz-Consulting-Group:blm-375

Conversation

@thedrow
Copy link
Copy Markdown
Contributor

@thedrow thedrow commented Aug 25, 2024

Note: Before submitting this pull request, please review our contributing
guidelines
.

Description

Fixes #9149.
Since ETA tasks will block the worker when using quorum queues we had to provide an alternative solution that will support ETA tasks on RabbitMQ.
This PR provides a solution based on NServiceBus' implementation of native delayed delivery.
The solution is based on a series of exchanges and queues as detailed in NServiceBus' documentation.
To use this feature you need to enable the broker_native_delayed_delivery configuration setting when using quorum queues.

@thedrow thedrow added this to the 5.5 milestone Aug 25, 2024
@thedrow thedrow requested a review from Nusnus August 25, 2024 08:49
@thedrow thedrow self-assigned this Aug 25, 2024
@thedrow thedrow marked this pull request as draft August 25, 2024 08:49
@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 25, 2024

Codecov Report

Attention: Patch coverage is 86.79245% with 7 lines in your changes missing coverage. Please review.

Project coverage is 78.15%. Comparing base (fadc1ae) to head (5fdf91e).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
celery/app/base.py 83.33% 3 Missing ⚠️
celery/utils/quorum_queues.py 80.00% 2 Missing ⚠️
celery/worker/consumer/delayed_delivery.py 90.47% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9207   +/-   ##
=======================================
  Coverage   78.15%   78.15%           
=======================================
  Files         151      153    +2     
  Lines       18984    19020   +36     
  Branches     2508     2516    +8     
=======================================
+ Hits        14837    14866   +29     
- Misses       3860     3866    +6     
- Partials      287      288    +1     
Flag Coverage Δ
unittests 78.13% <86.79%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@thedrow
Copy link
Copy Markdown
Contributor Author

thedrow commented Sep 11, 2024

@Nusnus Any idea why the quorum queues smoke tests are failing because the RabbitMQ container is not ready yet?

@Nusnus
Copy link
Copy Markdown
Member

Nusnus commented Sep 11, 2024

@Nusnus Any idea why the quorum queues smoke tests are failing because the RabbitMQ container is not ready yet?

Does it pass locally?

@thedrow
Copy link
Copy Markdown
Contributor Author

thedrow commented Sep 11, 2024

@Nusnus Any idea why the quorum queues smoke tests are failing because the RabbitMQ container is not ready yet?

Does it pass locally?

No it does not. I haven't done anything that can destabilize the test suite so I'm not sure what could be wrong.

@thedrow thedrow force-pushed the blm-375 branch 3 times, most recently from 0ae3885 to 7af9d39 Compare September 18, 2024 13:21
@thedrow thedrow marked this pull request as ready for review September 18, 2024 13:22
Copy link
Copy Markdown
Member

@Nusnus Nusnus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional comment: Add assertion error messages.
The only reason I bring this up is due to the nature of this change, which is relying on an algorithm to implement an ETA mechanism, so these errors could be crucial, and as the author of the changes, you will probably come up with the best error messages as you understand the protocol.

Food for thought.

Except that, please see my other comments. Something needs fixing too.

Comment thread celery/app/base.py Outdated
Comment thread celery/worker/consumer/delayed_delivery.py
Comment thread celery/worker/consumer/tasks.py Outdated
@Nusnus
Copy link
Copy Markdown
Member

Nusnus commented Sep 18, 2024

Also please make sure the CI fully passes 🙏

@thedrow
Copy link
Copy Markdown
Contributor Author

thedrow commented Oct 13, 2024

CI fails because I'm installing Kombu from Git. @Nusnus Once you release Kombu's RC I can change the requirements to that RC.

Copy link
Copy Markdown
Member

@Nusnus Nusnus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thedrow

CI fails because I'm installing Kombu from Git. @Nusnus Once you release Kombu's RC I can change the requirements to that RC.

Done. Please rebase on main.
The requirements are already updated.

Ping me if the CI fully passes for a review.
There have been many changes since my last review.

I'll do it today if the CI is green of course.

@thedrow
Copy link
Copy Markdown
Contributor Author

thedrow commented Oct 15, 2024

@Nusnus Ping.

Copy link
Copy Markdown
Member

@Nusnus Nusnus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have done a deep dive into the PR and found some issues.
I found at least 1 bug, some missing doc, cosmetic issues and some questions to make sure I fully understand the code, and some more minor stuff..

@thedrow please review my comments carefully and feel free to ask for clarifications.
I want this finished fast so we can include it in the next RC for Celery, so I’ll give you top priority after everything is fixed/answered.

Lastly, please do not dismiss/resolve my comments and let me review your response/fix to make sure there aren’t any gaps by resolving my own PR comments. We, the maintainers, need to show an example of work methodologies for the rest of the community, so I kindly ask you to join me in maintaining high standards.

Thanks!

Comment thread celery/app/base.py Outdated
Comment thread celery/app/defaults.py Outdated
Comment thread celery/app/defaults.py Outdated
Comment thread celery/worker/consumer/consumer.py
Comment thread docs/getting-started/backends-and-brokers/rabbitmq.rst
Comment thread t/smoke/tests/quorum_queues/test_native_delayed_delivery.py
Comment thread t/smoke/tests/quorum_queues/test_native_delayed_delivery.py
Comment thread t/unit/app/test_app.py Outdated
Comment thread celery/worker/consumer/tasks.py Outdated
Comment thread t/unit/worker/test_consumer.py Outdated
@Nusnus Nusnus mentioned this pull request Oct 15, 2024
4 tasks
@Jean-Daniel
Copy link
Copy Markdown

Out of curiosity, what are the benefit of the NServiceBus implementation versus using per-message TTL by specifying the expiration field when sending a delayed message ?

Copy link
Copy Markdown
Member

@Nusnus Nusnus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thedrow

CI fails because I'm installing Kombu from Git. @Nusnus Once you release Kombu's RC I can change the requirements to that RC.

Please take note the new Kombu RC release, which is a requirement for this PR, has introduced a new breaking bug as described in celery/kombu#2157.
Obviously, we do not want to revert any changes, but if we merge this PR without fixing Kombu (first IMHO), then we’ll introduce a dependency in Celery v5.5 to a confirmed broken (RC) version of Kombu.

Please review the Kombu’s report by @woutdenolf in addition to the PR comments from yesterday, as per my explanation above, it is closely related.

@thedrow
Copy link
Copy Markdown
Contributor Author

thedrow commented Oct 16, 2024

Out of curiosity, what are the benefit of the NServiceBus implementation versus using per-message TTL by specifying the expiration field when sending a delayed message ?

I haven't considered other implementations. This just works so there's no need to find other solutions.

Copy link
Copy Markdown
Member

@Nusnus Nusnus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replied to what was answered so far.
Please review my new comments and the rest of yesterday's comments, which are still awaiting your response/fix.

Ping me when you’re done.

P.S
Merge/Rebase on main to make sure you’re up to date.

Comment thread celery/app/defaults.py Outdated
Comment thread t/unit/app/test_app.py Outdated
Comment thread t/unit/worker/test_consumer.py Outdated
Comment thread celery/app/defaults.py Outdated
Comment thread celery/app/defaults.py Outdated
Comment thread docs/getting-started/backends-and-brokers/rabbitmq.rst Outdated
Comment thread t/smoke/tests/quorum_queues/test_native_delayed_delivery.py
Copy link
Copy Markdown
Member

@Nusnus Nusnus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done @thedrow 👏
Thank you for attending to all of the review issues during the work on this new core mechanism in Celery. The community is going to appreciate it a lot, trust me bro 😜

O25Z

Comment thread celery/worker/consumer/delayed_delivery.py
Comment thread docs/getting-started/backends-and-brokers/rabbitmq.rst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improved ETA support for quorum queues

4 participants