Skip to content

fix(celery): Prevent ChordError from Redis socket timeouts#1543

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/celery-redis-timeout
Open

fix(celery): Prevent ChordError from Redis socket timeouts#1543
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/celery-redis-timeout

Conversation

@sentry

@sentry sentry Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

The ChordError was observed when a Celery chord task completed, and during the process of updating the chord's state in Redis, a TimeoutError('Timeout reading from socket') occurred. This happened because the Redis connection pool returned a stale or closed socket, leading to an immediate timeout when attempting to read from it. Since Celery propagates any failure within a chord, this single connection issue caused the entire chord to fail.

This fix addresses the underlying Redis connection instability by enhancing the result_backend_transport_options in BaseCeleryConfig. Specifically, it:

  • Enables retry_on_timeout=True to automatically retry transient Redis socket timeouts, preventing them from being stored as task failures.
  • Sets health_check_interval=30 to periodically ping idle connections, helping to detect and evict stale connections before reuse.
  • Configures socket_timeout=5 and socket_connect_timeout=5 to ensure read and connection attempts fail quickly if the Redis server is unresponsive.
  • Activates socket_keepalive=True to enable TCP keepalive probes, allowing the operating system to detect and close dead connections at the network level.

These changes improve the resilience of Celery's Redis result backend, reducing the likelihood of ChordError due to network or Redis server-side connection issues.

Legal Boilerplate

Look, I get it. The entity doing business as "Codecov" is owned by Harness, Inc. In 2026 Harness acquired Codecov and as a result Harness is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Harness can use, modify, copy, and redistribute my contributions, under Harness's choice of terms.

Fixes WORKER-Z1A

@codspeed-hq

codspeed-hq Bot commented Jul 14, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 9 untouched benchmarks


Comparing seer/fix/celery-redis-timeout (5f19bb9) with main (0cfea15)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (d4ea985) during the generation of this report, so 0cfea15 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.84%. Comparing base (d4ea985) to head (5f19bb9).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1543   +/-   ##
=======================================
  Coverage   91.84%   91.84%           
=======================================
  Files        1325     1325           
  Lines       50923    50923           
  Branches     1631     1631           
=======================================
  Hits        46771    46771           
  Misses       3842     3842           
  Partials      310      310           
Flag Coverage Δ
apiunit 94.86% <ø> (ø)
workerintegration 58.61% <ø> (ø)
workerunit 90.39% <ø> (ø)

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

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

@codecov-notifications

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

0 participants