Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix connection retry with purge option at startup (#10102)#10114

Draft
harshang03 wants to merge 1 commit intocelery:mainfrom
harshang03:fix/10102-connection-retry-purge
Draft

Fix connection retry with purge option at startup (#10102)#10114
harshang03 wants to merge 1 commit intocelery:mainfrom
harshang03:fix/10102-connection-retry-purge

Conversation

@harshang03
Copy link
Contributor

When --purge is used, purge was called in Worker.on_start() before the Consumer established the broker connection, so it failed immediately instead of respecting broker_connection_retry_on_startup.

  • Defer purge until after Consumer's Connection step has connected (with retry). Run purge from Connection.start() when controller.purge is set, using the established connection.
  • Add purge_messages_with_connection() and _do_purge() on Worker so purge can run with an existing connection.

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

Description

Fixes #10102

Summary

With --purge, the worker called purge in on_start() before the Consumer had a broker connection, so it failed immediately instead of using broker_connection_retry_on_startup. Purge now runs after the Consumer’s Connection step has established the connection (with retry), using that connection.

Changes

  • celery/apps/worker.py: Removed purge from on_start(). Added purge_messages_with_connection(connection) and _do_purge(connection) so purge can run with an existing connection.
  • celery/worker/consumer/connection.py: After c.connect(), if c.controller.purge is set, call c.controller.purge_messages_with_connection(c.connection).

When --purge is used, purge was called in Worker.on_start() before the
Consumer established the broker connection, so it failed immediately
instead of respecting broker_connection_retry_on_startup.

- Defer purge until after Consumer's Connection step has connected
  (with retry). Run purge from Connection.start() when controller.purge
  is set, using the established connection.
- Add purge_messages_with_connection() and _do_purge() on Worker so
  purge can run with an existing connection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Connection retry do not work with purge option at startup

1 participant