From 2e30764cec9dbc4d3cb1088e609ab2812babcaff Mon Sep 17 00:00:00 2001 From: Bharath Vissapragada Date: Fri, 16 Aug 2024 07:27:08 -0700 Subject: [PATCH] tx: do not throw USE on expired transaction_ids Instead return INVALID_PRODUCER_ID_MAPPING like Apache Kafka https://github.com/apache/kafka/blob/cd47b3c1cce7a9f1881e40d38742b9ec8b30cf32/core/src/main/scala/kafka/coordinator/transaction/TransactionCoordinator.scala#L513C23-L513C50 (cherry picked from commit 84f42dba01dc3c1633145e14dd0c64a6ff61a59c) --- src/v/cluster/tx_gateway_frontend.cc | 2 +- tests/rptest/tests/transactions_test.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/v/cluster/tx_gateway_frontend.cc b/src/v/cluster/tx_gateway_frontend.cc index f4ad87517f6b..ba1540686208 100644 --- a/src/v/cluster/tx_gateway_frontend.cc +++ b/src/v/cluster/tx_gateway_frontend.cc @@ -2004,7 +2004,7 @@ tx_gateway_frontend::do_end_txn( "abort", request.transactional_id, pid); - err = tx_errc::unknown_server_error; + err = tx_errc::invalid_producer_id_mapping; } outcome->set_value(err); co_return err; diff --git a/tests/rptest/tests/transactions_test.py b/tests/rptest/tests/transactions_test.py index 52c1991df1ad..4d9fd4946059 100644 --- a/tests/rptest/tests/transactions_test.py +++ b/tests/rptest/tests/transactions_test.py @@ -401,8 +401,9 @@ def no_running_transactions(): try: producer.commit_transaction() assert False, "transaction should have been aborted by now." - except ck.KafkaException: - pass + except ck.KafkaException as e: + assert e.args[0].code( + ) == ck.KafkaError.INVALID_PRODUCER_ID_MAPPING, f"Invalid error thrown on expiration {e}" @cluster(num_nodes=3) def expired_tx_test(self):