Skip to content

Commit

Permalink
admin/server: fix rearm_log_level_timer
Browse files Browse the repository at this point in the history
_log_level_resets is a map<str, level_reset>, we want to extract the
next expiring level_reset to rearm the _log_level_timer.

previously we would extract the min_element based on the key (the logger
name)

so this sequence of actions
set log-level kafka trace 10
set log-level raft trace 10

only kafka would be expired, because once expired the next run would
pick again kafka, see that there is no expiration, and not rearm the
timer.
  • Loading branch information
andijcr committed May 13, 2024
1 parent 378f12e commit 57e7284
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/v/redpanda/admin_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
#include <limits>
#include <memory>
#include <numeric>
#include <ranges>
#include <stdexcept>
#include <system_error>
#include <type_traits>
Expand Down Expand Up @@ -622,16 +623,14 @@ void admin_server::log_exception(
void admin_server::rearm_log_level_timer() {
_log_level_timer.cancel();

auto next = std::min_element(
_log_level_resets.begin(),
_log_level_resets.end(),
[](const auto& a, const auto& b) {
return a.second.expires < b.second.expires;
});

if (next != _log_level_resets.end()) {
_log_level_timer.arm(next->second.expires);
if (_log_level_resets.empty()) {
return;
}

auto reset_values = _log_level_resets | std::views::values;
auto& lvl_rst = *std::ranges::min_element(
reset_values, std::less<>{}, &level_reset::expires);
_log_level_timer.arm(lvl_rst.expires);
}

void admin_server::log_level_timer_handler() {
Expand Down

0 comments on commit 57e7284

Please sign in to comment.