Skip to content

Commit

Permalink
tx_gateway_frontend: make tx cleaning less disruptive
Browse files Browse the repository at this point in the history
Cleaning tx session cache blocks `init_producer_id` request until the
size of the cache falls below the threshold. This commit makes it less
disruptive by allowing `init_producer_id` to procced if its tx id is
already in the cache so processing it doesn't make the situation worse.
  • Loading branch information
rystsov committed Sep 27, 2023
1 parent 397e3c8 commit 3d51861
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/v/cluster/tx_gateway_frontend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,13 @@ ss::future<cluster::init_tm_tx_reply> tx_gateway_frontend::limit_init_tm_tx(
}
auto term = term_opt.value();

auto units = co_await stm->lock_tx(tx_id, "init_tm_tx");
if ((co_await stm->get_tx(tx_id)).has_value()) {
co_return co_await do_init_tm_tx(
stm, term, tx_id, transaction_timeout_ms, timeout, expected_pid);
}
units.return_all();

if (stm->tx_cache_size() > _max_transactions_per_coordinator()) {
// lock is sloppy and doesn't guarantee that tx_cache_size
// never exceeds _max_transactions_per_coordinator. init_tm_tx
Expand Down Expand Up @@ -1197,7 +1204,7 @@ ss::future<cluster::init_tm_tx_reply> tx_gateway_frontend::limit_init_tm_tx(
init_units.return_all();
}

auto units = co_await stm->lock_tx(tx_id, "init_tm_tx");
units = co_await stm->lock_tx(tx_id, "init_tm_tx");

co_return co_await do_init_tm_tx(
stm, term, tx_id, transaction_timeout_ms, timeout, expected_pid);
Expand Down

0 comments on commit 3d51861

Please sign in to comment.