Skip to content

Commit

Permalink
cluster: swallog+log unexpected exceptions in report_metrics
Browse files Browse the repository at this point in the history
This can happen during shutdown, for the exception types
that ssx::spawn_with_gate doesn't already handle.  Rather
rare in real life but much more frequent in tests like
test_cluster_rpunit, resulting in an "ignored exceptional
future" error.

Fixes redpanda-data#4807
  • Loading branch information
jcsp committed May 23, 2022
1 parent 9198ee5 commit 3c35d78
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/v/cluster/metrics_reporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,16 @@ ss::future<> metrics_reporter::stop() {
}

void metrics_reporter::report_metrics() {
ssx::spawn_with_gate(_gate, [this] {
return do_report_metrics().finally([this] {
if (!_gate.is_closed()) {
_tick_timer.arm(
config::shard_local_cfg().metrics_reporter_tick_interval());
}
});
ssx::background = ssx::spawn_with_gate_then(_gate, [this] {
return do_report_metrics().finally([this] {
if (!_gate.is_closed()) {
_tick_timer.arm(
config::shard_local_cfg()
.metrics_reporter_tick_interval());
}
});
}).handle_exception([](const std::exception_ptr& e) {
vlog(clusterlog.warn, "Exception reporting metrics: {}", e);
});
}

Expand Down

0 comments on commit 3c35d78

Please sign in to comment.