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).
This commit is contained in:
Kamil Braun
2024-01-18 14:06:28 +01:00
parent f6d43779af
commit 689d59fccd

View File

@@ -304,9 +304,6 @@ void fsm::become_candidate(bool is_prevote, bool is_leadership_transfer) {
}
future<fsm_output> 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_output> 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