Skip to content

Conversation

@sumo1998
Copy link
Contributor

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

Description

When the consumer fails to connect to broker, the error logs retry counter stalls after some time. More can be found in this issue : #9340

Design

Maintains a counter in the consumer to track retry attempts, this is because the interval returned from kombu is not sufficient indicator for the retry count and will be interval_max after a few retry attempts.

Changes

  • Changes for the retry counter
  • Fixing a linter issue (additional whitespace on empty line)

@codecov
Copy link

codecov bot commented Sep 25, 2025

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 78.67%. Comparing base (943dfb8) to head (0a197b7).
⚠️ Report is 67 commits behind head on main.

Files with missing lines Patch % Lines
celery/worker/consumer/consumer.py 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9911      +/-   ##
==========================================
- Coverage   78.67%   78.67%   -0.01%     
==========================================
  Files         153      153              
  Lines       19291    19295       +4     
  Branches     2568     2569       +1     
==========================================
+ Hits        15177    15180       +3     
  Misses       3816     3816              
- Partials      298      299       +1     
Flag Coverage Δ
unittests 78.65% <75.00%> (-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.

@sumo1998 sumo1998 force-pushed the log/fix-broker-retry-count-log branch from 9897610 to 36e41f6 Compare September 25, 2025 06:32
@auvipy auvipy requested review from auvipy and Copilot September 25, 2025 12:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where the broker connection retry attempt counter in error logs becomes stalled after some retry attempts. The problem was that the retry counter was calculated from the connection interval, which plateaus at a maximum value, making the displayed retry count inaccurate.

  • Adds a dedicated counter to track actual retry attempts instead of deriving from interval
  • Updates error logging to use the new counter for accurate retry count display
  • Resets the counter when connection is successfully established

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
celery/worker/consumer/consumer.py Adds broker_connection_retry_attempt counter and updates retry logic to use it instead of interval-based calculation
t/unit/worker/test_consumer.py Updates test to reflect corrected retry interval behavior in error messages

@sumo1998 sumo1998 force-pushed the log/fix-broker-retry-count-log branch 2 times, most recently from 50a0785 to 48a2897 Compare September 26, 2025 05:41
@auvipy auvipy added this to the 5.6.0 milestone Sep 27, 2025
@Nusnus Nusnus requested a review from Copilot September 27, 2025 14:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

@auvipy auvipy requested a review from Nusnus September 28, 2025 16:41
@Nusnus Nusnus force-pushed the log/fix-broker-retry-count-log branch from e143136 to 0a197b7 Compare September 28, 2025 17:07
@auvipy auvipy merged commit e7a9550 into celery:main Sep 28, 2025
108 of 109 checks passed
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.

2 participants