From 7eafcf248c4e07aefa7c1e8a1fb1437c2b56f58d Mon Sep 17 00:00:00 2001 From: Yaming Kuang <1477567+yamingk@users.noreply.github.com> Date: Mon, 22 Apr 2024 16:08:39 -0700 Subject: [PATCH] don't truncate on if compact_lsn is zero (#389) --- conanfile.py | 2 +- src/lib/replication/log_store/home_raft_log_store.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/conanfile.py b/conanfile.py index a83dea6b4..e6c915935 100644 --- a/conanfile.py +++ b/conanfile.py @@ -5,7 +5,7 @@ class HomestoreConan(ConanFile): name = "homestore" - version = "6.3.1" + version = "6.3.3" 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 4d9b2443a..1bef25d36 100644 --- a/src/lib/replication/log_store/home_raft_log_store.cpp +++ b/src/lib/replication/log_store/home_raft_log_store.cpp @@ -66,11 +66,13 @@ void HomeRaftLogStore::truncate(uint32_t num_reserved_cnt, repl_lsn_t compact_ls auto const last_lsn = last_index(); auto const start_lsn = start_index(); - if (start_lsn + num_reserved_cnt >= last_lsn) { + // compact_lsn will be zero on first time boot, so we should not truncate in that case. + if (compact_lsn == 0 || (start_lsn + num_reserved_cnt >= last_lsn)) { REPL_STORE_LOG(DEBUG, - "Store={} LogDev={}: Skipping truncating because of reserved logs entries is not enough. " - "start_lsn={}, resv_cnt={}, last_lsn={}", - m_logstore_id, m_logdev_id, start_lsn, num_reserved_cnt, last_lsn); + "Store={} LogDev={}: Skipping truncating because of reserved logs entries is not enough or " + "compact_lsn is zero. " + "start_lsn={}, resv_cnt={}, last_lsn={}, compact_lsn={}", + m_logstore_id, m_logdev_id, start_lsn, num_reserved_cnt, last_lsn, compact_lsn); return; } else { //