From 689d59fccd9f44c69d5bfef922fdfd09cc75da6d Mon Sep 17 00:00:00 2001 From: Kamil Braun Date: Thu, 18 Jan 2024 14:06:28 +0100 Subject: [PATCH] raft: fsm: move trace message from `poll_output` to `has_output` In a later commit we'll move `poll_output` out of `fsm` and it won't have access to internals logged by this message (`_log.stable_idx()`). Besides, having it in `has_output` gives a more detailed trace. In particular we can now see values such as `stable_idx` and `last_idx` from the moment of returning a new fsm output, not only when poll started waiting for it (a lot of time can pass between these two events). --- raft/fsm.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/raft/fsm.cc b/raft/fsm.cc index 929af2cb3e..92545d887d 100644 --- a/raft/fsm.cc +++ b/raft/fsm.cc @@ -304,9 +304,6 @@ void fsm::become_candidate(bool is_prevote, bool is_leadership_transfer) { } future fsm::poll_output() { - logger.trace("fsm::poll_output() {} stable index: {} last index: {}", - _my_id, _log.stable_idx(), _log.last_idx()); - co_await _sm_events.when(std::bind_front(&fsm::has_output, this)); while (utils::get_local_injector().enter("fsm::poll_output/pause")) { @@ -316,6 +313,9 @@ future fsm::poll_output() { } bool fsm::has_output() const { + logger.trace("fsm::has_output() {} stable index: {} last index: {}", + _my_id, _log.stable_idx(), _log.last_idx()); + auto diff = _log.last_idx() - _log.stable_idx(); return diff > 0 || !_messages.empty() || !_observed.is_equal(*this) || _output.max_read_id_with_quorum