Skip to content

Commit

Permalink
Adding logs in handle_raft_event as preparation.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
xiaoxichen committed Aug 21, 2024
1 parent f1be515 commit a2969ec
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/replication/repl_dev/raft_repl_dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit a2969ec

Please sign in to comment.