Skip to content

Commit

Permalink
txns: fix list txns failure when it's used before find_coordinator
Browse files Browse the repository at this point in the history
find_coordinator creates txn coordinator's topic when it's used for
the first time. list txns api expects the topic to be already created
so it used to fail when the api was invoked before find_coordinator.
Fixed the problem by creating the topic on the first list txns call.

fixes #11947

(cherry picked from commit 85ad993)
  • Loading branch information
rystsov committed Aug 7, 2023
1 parent 01ed272 commit 1b186e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/v/cluster/tx_gateway_frontend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2953,6 +2953,12 @@ ss::future<> tx_gateway_frontend::do_expire_old_tx(

ss::future<tx_gateway_frontend::return_all_txs_res>
tx_gateway_frontend::get_all_transactions() {
if (!_metadata_cache.local().contains(model::tx_manager_nt)) {
if (!co_await try_create_tx_topic()) {
co_return tx_errc::unknown_server_error;
}
}

auto shard = _shard_table.local().shard_for(model::tx_manager_ntp);

if (!shard.has_value()) {
Expand Down
7 changes: 6 additions & 1 deletion tests/rptest/tests/transaction_kafka_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, test_context):
"tx_timeout_delay_ms": 10000000,
"abort_timed_out_transactions_interval_ms":
10000000,
'enable_leader_balancer': False
"enable_leader_balancer": False
})

self.kafka_cli = KafkaCliTools(self.redpanda, "3.0.0")
Expand Down Expand Up @@ -106,6 +106,11 @@ def test_describe_transactions(self):
tpoic_partition = f"{topic}-{partition}"
assert tpoic_partition in expected_partitions

@cluster(num_nodes=3)
def test_empty_list_transactions(self):
txs_info = self.kafka_cli.list_transactions()
assert len(txs_info) == 0

@cluster(num_nodes=3)
def test_list_transactions(self):
producer1 = ck.Producer({
Expand Down

0 comments on commit 1b186e9

Please sign in to comment.