Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions faust/transport/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,19 @@ async def on_rebalance(
)
await T(self._stop_transactions, tids=revoked_tids)(revoked_tids)

# Start produers for assigned partitions
assigned_tids = sorted(self._tps_to_transactional_ids(assigned))
if assigned_tids:
# Start producers only for partitions newly assigned in this rebalance.
newly_assigned_tids = sorted(self._tps_to_transactional_ids(newly_assigned))
if newly_assigned_tids:
self.log.info(
"Starting %r transactional %s for %r assigned %s...",
len(assigned_tids),
pluralize(len(assigned_tids), "producer"),
len(assigned),
pluralize(len(assigned), "partition"),
len(newly_assigned_tids),
pluralize(len(newly_assigned_tids), "producer"),
len(newly_assigned),
pluralize(len(newly_assigned), "partition"),
)
await T(self._start_transactions, tids=newly_assigned_tids)(
newly_assigned_tids
)
await T(self._start_transactions, tids=assigned_tids)(assigned_tids)

async def _stop_transactions(self, tids: Iterable[str]) -> None:
T = traced_from_parent_span()
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/transport/test_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ async def test_on_rebalance(self, *, manager):
manager._stop_transactions = AsyncMock()
manager._start_transactions = AsyncMock()

assigned = {TP2}
assigned = {TP1, TP2}
revoked = {TP3}
newly_assigned = {TP2}
await manager.on_rebalance(assigned, revoked, newly_assigned)
Expand Down
Loading