Skip to content

Forward chord body routing options to chord_unlock - #10442

Merged
auvipy merged 14 commits into
celery:mainfrom
phanky1:chord-unlock-routing
Sep 5, 2026
Merged

auvipy merged 14 commits into
celery:mainfrom
phanky1:chord-unlock-routing

Conversation

@phanky1

@phanky1 phanky1 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Description

Closes: #6690

fallback_chord_unlock() forwards only queue and priority from the chord body's options when publishing celery.chord_unlock. A headers exchange routes on the message headers, so the celery.chord_unlock matches no binding and is discarded.

This PR also forwards exchange, exchange_type, routing_key and headers from the body's options, skipping any of them that is a stamp.

@codecov

codecov Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.87%. Comparing base (53b3245) to head (83add28).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10442      +/-   ##
==========================================
+ Coverage   88.86%   88.87%   +0.01%     
==========================================
  Files         153      153              
  Lines       19986    20006      +20     
  Branches     2336     2342       +6     
==========================================
+ Hits        17760    17780      +20     
  Misses       1929     1929              
  Partials      297      297              
Flag Coverage Δ
unittests 88.85% <100.00%> (+0.01%) ⬆️

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.

@auvipy
auvipy requested review from auvipy and a lite review from Copilot August 16, 2026 15:57
@auvipy auvipy added this to the 5.7.0 milestone Aug 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 chord unlock routing for non-default AMQP routing setups (notably headers exchanges) by forwarding relevant routing options from the chord body signature into the internally-published celery.chord_unlock task, preventing the unlock message from missing bindings and being dropped.

Changes:

  • Forward exchange, exchange_type, routing_key, and headers from the chord body’s Signature.options into fallback_chord_unlock()’s apply_async() call.
  • Skip forwarding any of those options if they are listed in the body’s stamped_headers (so stamping semantics aren’t accidentally treated as transport routing).
  • Add unit coverage asserting routing options are forwarded (and stamped routing options are not).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
celery/backends/base.py Extends fallback_chord_unlock() to forward additional routing-related apply_async options from the chord body, enabling headers exchange routing to work.
t/unit/backends/test_base.py Adds tests verifying routing options are forwarded to celery.chord_unlock and that stamped routing options are excluded.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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

can we also add integration test for this? may be we got a reproducing script attached in the script

@phanky1

phanky1 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

can we also add integration test for this? may be we got a reproducing script attached in the script

I added a smoke test for this.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread celery/backends/base.py Resolved
@auvipy

auvipy commented Sep 3, 2026

Copy link
Copy Markdown
Member

@goingforstudying-ctrl can you try and review this please? since you recently handle a canvas based issue

@goingforstudying-ctrl goingforstudying-ctrl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I reviewed all four changed files and cross-checked the routing path through fallback_chord_unlock(), Task.retry(), the router, and Kombu publishing.

I also validated the current head against RabbitMQ with a deliberately slow header task and a 1-second chord retry interval. The unlock task retried repeatedly and the callback completed successfully. The routing-option forwarding and stamped-option filtering look correct for the reported headers-exchange case.

Non-blocking: it would still be useful to make the smoke test deterministically exercise at least one retry, so that behavior is protected explicitly.

LGTM.

@phanky1
phanky1 force-pushed the chord-unlock-routing branch from cc33a49 to ca6c552 Compare September 4, 2026 13:42
@auvipy
auvipy merged commit e997039 into celery:main Sep 5, 2026
18 of 19 checks passed
@phanky1
phanky1 deleted the chord-unlock-routing branch September 5, 2026 09:40
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.

Exchange type headers and chords

4 participants