Repository navigation
fix: start and stop MultiBroker result backend once - #727
Open
zakharkiv-vitalik wants to merge 1 commit into
Open
zakharkiv-vitalik wants to merge 1 commit into
zakharkiv-vitalik wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #727 +/- ##
==========================================
- Coverage 86.06% 86.05% -0.01%
==========================================
Files 69 69
Lines 2778 2769 -9
==========================================
- Hits 2391 2383 -8
+ Misses 387 386 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
MultiBroker.with_result_backend() assigned the same backend to every inner broker, so each of them started and stopped it too: N+1 calls for N inner brokers, leaking resources opened in startup() and failing on repeated shutdown(). Tasks are registered only on the MultiBroker, so kicks, results and progress always use its backend and inner brokers never need one. Drop the override and keep the backend on the MultiBroker only.
zakharkiv-vitalik
force-pushed
the
fix/multibroker-shared-result-backend
branch
from
November 18, 2026 06:52
392d057 to
eb939c8
Compare
nkhitrov
approved these changes
Nov 18, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #726
Problem
MultiBroker.with_result_backend()assigned the same backend instance to every inner broker. Since everyAsyncBrokerstarts and stops its ownresult_backend, a shared backend got N+1startup()/shutdown()calls for N inner brokers: resources opened instartup()(e.g. connection pools) leaked and repeatedshutdown()could fail. See #726 for a reproduction.Solution
The propagation was needed in the first version of #723, when tasks were registered on inner brokers. After the review (comment) tasks are registered only on the
MultiBroker, so the kicker, the receiver and the progress tracker always use its backend, and inner brokers never read theirs.with_result_backend()override, the baseAsyncBrokerimplementation sets the backend on theMultiBrokeronly;Tests
test_shared_result_backend_started_once/test_shared_result_backend_shut_down_once— fail on master with3 == 1, pass now;test_with_result_backend_propagates_to_inner_brokers→test_with_result_backend_is_not_shared_with_inner_brokers;test_receiver_processes_tasks_from_all_brokers(kiq()→ worker →wait_result()) still passes without propagation.pytest(401 passed),ruff,black,mypy,typospass locally.