Skip to content

Native Delayed Delivery in RabbitMQ - #9207

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

Nusnus merged 48 commits into
celery:mainfrom
Katz-Consulting-Group:blm-375

Conversation

@thedrow

@thedrow thedrow commented Aug 25, 2024 •

Copy link
Copy Markdown
Contributor

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.

@codecov

codecov Bot commented Aug 25, 2024 •

Copy link
Copy Markdown

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.

@auvipy
auvipy self-requested a review August 26, 2024 05:59
@thedrow

thedrow commented Sep 11, 2024

Copy link
Copy Markdown
Contributor Author

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

@Nusnus

Nusnus commented Sep 11, 2024

Copy link
Copy Markdown
Member

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

Does it pass locally?

@thedrow

thedrow commented Sep 11, 2024

Copy link
Copy Markdown
Contributor Author

@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.

@Nusnus Nusnus left a comment

Copy link
Copy Markdown
Member

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 Resolved
Comment thread celery/worker/consumer/tasks.py Resolved
@Nusnus

Nusnus commented Sep 18, 2024

Copy link
Copy Markdown
Member

Also please make sure the CI fully passes 🙏

@thedrow

thedrow commented Oct 13, 2024

Copy link
Copy Markdown
Contributor Author

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

@Nusnus Nusnus left a comment

Copy link
Copy Markdown
Member

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

thedrow commented Oct 15, 2024

Copy link
Copy Markdown
Contributor Author

@Nusnus Ping.

@Nusnus Nusnus left a comment

Copy link
Copy Markdown
Member

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 Resolved
Comment thread celery/app/defaults.py Resolved
Comment thread celery/app/defaults.py Resolved
Comment thread celery/worker/consumer/consumer.py Resolved
Comment thread t/unit/app/test_app.py Resolved
Comment thread celery/worker/consumer/tasks.py Resolved
Comment thread t/unit/worker/test_consumer.py Resolved
@Nusnus Nusnus mentioned this pull request Oct 15, 2024
3 of 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 ?

@Nusnus Nusnus left a comment

Copy link
Copy Markdown
Member

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

thedrow commented Oct 16, 2024

Copy link
Copy Markdown
Contributor Author

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.

@Nusnus Nusnus left a comment

Copy link
Copy Markdown
Member

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 Resolved
Comment thread t/unit/app/test_app.py Resolved
Comment thread t/unit/worker/test_consumer.py Resolved
Comment thread celery/app/defaults.py Resolved
Comment thread celery/app/defaults.py Resolved
@Nusnus Nusnus mentioned this pull request Oct 17, 2024
3 of 6 tasks

@Nusnus Nusnus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed again. Don’t forget to rebase on main.
See new comments.

Comment thread celery/app/defaults.py Resolved
Comment thread celery/app/defaults.py Resolved
Comment thread t/unit/worker/test_consumer.py Resolved
@thedrow

thedrow commented Nov 13, 2024

Copy link
Copy Markdown
Contributor Author

@Nusnus I addressed most of your concerns excluding the bug which I don't know how to fix.
Please re-review.

@thedrow

thedrow commented Nov 13, 2024

Copy link
Copy Markdown
Contributor Author

The tests are failing because of codecov. I don't know why.
See here.

@Nusnus

Nusnus commented Nov 16, 2024

Copy link
Copy Markdown
Member

The tests are failing because of codecov. I don't know why.
See here.

Rebase on main, there's a new codecov version.

@Nusnus

Nusnus commented Nov 16, 2024

Copy link
Copy Markdown
Member

@Nusnus I addressed most of your concerns excluding the bug which I don't know how to fix.
Please re-review.

Thanks! 🙏
I'll review it again tomorrow/next day!

@Nusnus Nusnus left a comment

Copy link
Copy Markdown
Member

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

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