From 8db957993f2abbbc83ac6e64edd8cebaf950bce1 Mon Sep 17 00:00:00 2001 From: Bharath Vissapragada Date: Mon, 20 May 2024 23:02:20 -0700 Subject: [PATCH] producer_state_mgr: limit number of evictions per tick .. to avoid reactor stalls. --- src/v/cluster/producer_state_manager.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/v/cluster/producer_state_manager.cc b/src/v/cluster/producer_state_manager.cc index 5a9f806f1031..97fbd707b52b 100644 --- a/src/v/cluster/producer_state_manager.cc +++ b/src/v/cluster/producer_state_manager.cc @@ -107,7 +107,11 @@ void producer_state_manager::do_evict_excess_producers() { } vlog(clusterlog.debug, "producer eviction tick"); auto it = _lru_producers.begin(); - while (it != _lru_producers.end() && can_evict_producer(*it)) { + // to avoid reactor stalls. + static constexpr auto max_evictions_per_tick = 10000; + int evicted_so_far = 0; + while (evicted_so_far++ < max_evictions_per_tick + && it != _lru_producers.end() && can_evict_producer(*it)) { auto it_copy = it; ++it; auto& state = *it_copy;