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
11 changes: 7 additions & 4 deletions faust/transport/drivers/aiokafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,13 +572,16 @@ def _create_worker_consumer(
conf = self.app.conf
if self.consumer.in_transaction:
isolation_level = "read_committed"
# Table recovery depends on app.assignor state to map changelog
# active/standby partitions. Keep Faust assignor enabled whenever
# this app has changelog tables configured.
# Transaction IDs depend on app.assignor topic groups. Table recovery
# also needs assignment metadata when changelog tables are configured.
has_changelog_tables = bool(self.app.tables.changelog_topics)
self._assignor = (
self.app.assignor
if self.app.conf.table_standby_replicas > 0 or has_changelog_tables
if (
self.consumer.in_transaction
or self.app.conf.table_standby_replicas > 0
or has_changelog_tables
)
else RoundRobinPartitionAssignor
)
auth_settings = credentials_to_aiokafka_auth(
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/transport/drivers/test_aiokafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,17 @@ def test__create_worker_consumer__uses_roundrobin_without_tables(
cthread._create_worker_consumer(transport)
assert cthread._assignor is mod.RoundRobinPartitionAssignor

def test__create_worker_consumer__uses_faust_assignor_for_transactions(
self, *, cthread, app
):
app.conf.table_standby_replicas = 0
app.tables._changelogs.clear()
cthread.consumer.in_transaction = True
transport = cthread.transport
with patch("aiokafka.AIOKafkaConsumer"):
cthread._create_worker_consumer(transport)
assert cthread._assignor is app.assignor

def test__create_worker_consumer__uses_faust_assignor_with_changelog_topics(
self, *, cthread, app
):
Expand Down
Loading