From 79b5a75ded8bd4dec613d728080b068a291df0bf Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Tue, 20 Feb 2024 12:54:03 +0300 Subject: [PATCH] topology_coordinator: Add action_failed() helper It checks if the action holder holds a failed action. Signed-off-by: Pavel Emelyanov --- service/topology_coordinator.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/service/topology_coordinator.cc b/service/topology_coordinator.cc index 93e8c0d069..c647ac6221 100644 --- a/service/topology_coordinator.cc +++ b/service/topology_coordinator.cc @@ -835,6 +835,10 @@ class topology_coordinator : public endpoint_lifecycle_subscriber { seastar::gate _async_gate; + bool action_failed(background_action_holder& holder) const { + return holder && holder->failed(); + } + // This function drives background_action_holder towards "executed successfully" // by starting the action if it is not already running or if the previous instance // of the action failed. If the action is already running, it does nothing. @@ -842,7 +846,7 @@ class topology_coordinator : public endpoint_lifecycle_subscriber { bool advance_in_background(locator::global_tablet_id gid, background_action_holder& holder, const char* name, std::function()> action) { if (!holder || holder->failed()) { - if (holder && holder->failed()) { + if (action_failed(holder)) { // Prevent warnings about abandoned failed future. Logged below. holder->ignore_ready_future(); } @@ -1043,7 +1047,7 @@ class topology_coordinator : public endpoint_lifecycle_subscriber { [] { throw std::runtime_error("stream_tablet failed due to error injection"); }); } - if (tablet_state.streaming && tablet_state.streaming->failed()) { + if (action_failed(tablet_state.streaming)) { if (check_excluded_replicas()) { transition_to_with_barrier(locator::tablet_transition_stage::cleanup_target); break;