From a2969ec7cd9cb984188098e9ea7cd24a565df62e Mon Sep 17 00:00:00 2001 From: Xiaoxi Chen Date: Wed, 21 Aug 2024 02:55:57 -0700 Subject: [PATCH] Adding logs in handle_raft_event as preparation. We can get LSN of logs, as well as where the leader is and where our last_commit index is. These information can be helpful for us to determine if we are catching up as well as de-deup already commited log. Signed-off-by: Xiaoxi Chen --- src/lib/replication/repl_dev/raft_repl_dev.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/replication/repl_dev/raft_repl_dev.cpp b/src/lib/replication/repl_dev/raft_repl_dev.cpp index dd20354d7..6c3a951fc 100644 --- a/src/lib/replication/repl_dev/raft_repl_dev.cpp +++ b/src/lib/replication/repl_dev/raft_repl_dev.cpp @@ -1030,6 +1030,11 @@ std::pair< bool, nuraft::cb_func::ReturnCode > RaftReplDev::handle_raft_event(nu if (type == nuraft::cb_func::Type::GotAppendEntryReqFromLeader) { auto raft_req = r_cast< nuraft::req_msg* >(param->ctx); auto const& entries = raft_req->log_entries(); + auto start_lsn = raft_req->get_last_log_idx() + 1; + RD_LOGD("Raft channel: Received {} append entries on follower from leader, term {}, lsn {} ~ {} , my commited " + "lsn {} , leader commmited lsn {}", + entries.size(), raft_req->get_last_log_term(), start_lsn, start_lsn + entries.size() - 1, m_commit_upto_lsn.load(), + raft_req->get_commit_idx()); if (!entries.empty()) { RD_LOGT("Raft channel: Received {} append entries on follower from leader, localizing them",