From eaaa5dc06e4ba3a3f353e59289fdd469db34638a Mon Sep 17 00:00:00 2001 From: Xiaoxi Chen Date: Sun, 10 Nov 2024 21:25:17 -0700 Subject: [PATCH] fix ut. Previously commit dont flush the over-written log, and the log_entries only look at flushed logs. As a result, the over-written log was not included in the log_entries() result which breaks the UT. The UT was running in master, because we dont at the over_written entry into cache and the entry_at() call will inline flush this entry. After adding it to cache it served from cache without flushing. Signed-off-by: Xiaoxi Chen --- src/lib/replication/log_store/home_raft_log_store.cpp | 3 +++ 1 file changed, 3 insertions(+) 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 649555a37..144f2c01b 100644 --- a/src/lib/replication/log_store/home_raft_log_store.cpp +++ b/src/lib/replication/log_store/home_raft_log_store.cpp @@ -190,6 +190,9 @@ void HomeRaftLogStore::write_at(ulong index, nuraft::ptr< nuraft::log_entry >& e std::unique_lock lk(m_mutex); m_log_entry_cache[position_in_cache] = std::make_pair(index, entry); } + + // flushing the log before returning to ensure new(over-written) log is persisted to disk. + end_of_append_batch(index, 1); } void HomeRaftLogStore::end_of_append_batch(ulong start, ulong cnt) {