From 3407c65c06cf9e9d2f7a3d0c92645d0a6b66b962 Mon Sep 17 00:00:00 2001 From: Jie Yao Date: Mon, 23 Dec 2024 02:31:12 -0700 Subject: [PATCH] fix HomeRaftLogStore::last_entry according to the contract, we should return a dummy log entry if the index is out of range. --- conanfile.py | 2 +- src/lib/replication/log_store/home_raft_log_store.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/conanfile.py b/conanfile.py index 087d8ca98..75fb41167 100644 --- a/conanfile.py +++ b/conanfile.py @@ -9,7 +9,7 @@ class HomestoreConan(ConanFile): name = "homestore" - version = "6.6.1" + version = "6.6.2" homepage = "/~https://github.com/eBay/Homestore" description = "HomeStore Storage Engine" diff --git a/src/lib/replication/log_store/home_raft_log_store.cpp b/src/lib/replication/log_store/home_raft_log_store.cpp index 1c09afa91..f0f792276 100644 --- a/src/lib/replication/log_store/home_raft_log_store.cpp +++ b/src/lib/replication/log_store/home_raft_log_store.cpp @@ -147,8 +147,11 @@ nuraft::ptr< nuraft::log_entry > HomeRaftLogStore::last_entry() const { auto log_bytes = m_log_store->read_sync(max_seq); nle = to_nuraft_log_entry(log_bytes); } catch (const std::exception& e) { - REPL_STORE_LOG(ERROR, "last_entry() out_of_range={}", max_seq); - throw e; + // all the log entries are truncated, so we should return a dummy log entry. + REPL_STORE_LOG(ERROR, "last_entry() out_of_range={}, {}", max_seq, e.what()); + // according to the contract, we should return a dummy log entry if the index is out of range. + // /~https://github.com/eBay/NuRaft/blob/50e2f949503081262cb21923e633eaa8dacad8fa/include/libnuraft/log_store.hxx#L56 + nle = m_dummy_log_entry; } return nle;