From ca6efec28c7cce0a96c13326eb6b20fca6bc41d4 Mon Sep 17 00:00:00 2001 From: Ravi Nagarjun Akella Date: Mon, 5 Aug 2024 12:04:01 -0700 Subject: [PATCH] do not assert lsn condition in On_commit during log replay in restart --- src/lib/replication/repl_dev/raft_repl_dev.cpp | 10 ++++++---- src/lib/replication/repl_dev/raft_repl_dev.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/lib/replication/repl_dev/raft_repl_dev.cpp b/src/lib/replication/repl_dev/raft_repl_dev.cpp index fdb2495e5..fb2868f15 100644 --- a/src/lib/replication/repl_dev/raft_repl_dev.cpp +++ b/src/lib/replication/repl_dev/raft_repl_dev.cpp @@ -746,7 +746,7 @@ void RaftReplDev::handle_fetch_data_response(sisl::GenericClientResponse respons RD_DBG_ASSERT_EQ(total_size, 0, "Total size mismatch, some data is not consumed"); } -void RaftReplDev::handle_commit(repl_req_ptr_t rreq) { +void RaftReplDev::handle_commit(repl_req_ptr_t rreq, bool recovery) { if (rreq->local_blkid().is_valid()) { if (data_service().commit_blk(rreq->local_blkid()) != BlkAllocStatus::SUCCESS) { if (hs()->device_mgr()->is_boot_in_degraded_mode() && m_log_store_replay_done) @@ -771,8 +771,10 @@ void RaftReplDev::handle_commit(repl_req_ptr_t rreq) { m_listener->on_commit(rreq->lsn(), rreq->header(), rreq->key(), rreq->local_blkid(), rreq); } - auto prev_lsn = m_commit_upto_lsn.exchange(rreq->lsn()); - RD_DBG_ASSERT_GT(rreq->lsn(), prev_lsn, "Out of order commit of lsns, it is not expected in RaftReplDev"); + if (!recovery) { + auto prev_lsn = m_commit_upto_lsn.exchange(rreq->lsn()); + RD_DBG_ASSERT_GT(rreq->lsn(), prev_lsn, "Out of order commit of lsns, it is not expected in RaftReplDev"); + } if (!rreq->is_proposer()) { rreq->clear(); } } @@ -1168,7 +1170,7 @@ void RaftReplDev::on_log_found(logstore_seq_num_t lsn, log_buffer buf, void* ctx m_listener->on_pre_commit(lsn, entry_to_hdr(jentry), entry_to_key(jentry), nullptr); // 3. Commit the log entry - handle_commit(rreq); + handle_commit(rreq, true /* recovery */); } } // namespace homestore diff --git a/src/lib/replication/repl_dev/raft_repl_dev.h b/src/lib/replication/repl_dev/raft_repl_dev.h index a393d0f6b..f3602bee8 100644 --- a/src/lib/replication/repl_dev/raft_repl_dev.h +++ b/src/lib/replication/repl_dev/raft_repl_dev.h @@ -181,7 +181,7 @@ class RaftReplDev : public ReplDev, //////////////// Methods needed for other Raft classes to access ///////////////// void use_config(json_superblk raft_config_sb); - void handle_commit(repl_req_ptr_t rreq); + void handle_commit(repl_req_ptr_t rreq, bool recovery = false); repl_req_ptr_t repl_key_to_req(repl_key const& rkey) const; repl_req_ptr_t applier_create_req(repl_key const& rkey, journal_type_t code, sisl::blob const& user_header, sisl::blob const& key, uint32_t data_size, bool is_data_channel);