From 1f85dd3214b940f555d2aca1b4912f76cfe2ad75 Mon Sep 17 00:00:00 2001 From: Jie Yao Date: Mon, 26 Aug 2024 00:57:45 -0700 Subject: [PATCH] fix write_snapshot_data --- conanfile.py | 2 +- src/tests/test_raft_repl_dev.cpp | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/conanfile.py b/conanfile.py index 30d53f709..870760692 100644 --- a/conanfile.py +++ b/conanfile.py @@ -9,7 +9,7 @@ class HomestoreConan(ConanFile): name = "homestore" - version = "6.4.51" + version = "6.4.52" homepage = "https://github.com/eBay/Homestore" description = "HomeStore Storage Engine" diff --git a/src/tests/test_raft_repl_dev.cpp b/src/tests/test_raft_repl_dev.cpp index 3b497bd49..550ac9b4c 100644 --- a/src/tests/test_raft_repl_dev.cpp +++ b/src/tests/test_raft_repl_dev.cpp @@ -136,7 +136,6 @@ class TestReplicatedDB : public homestore::ReplDevListener { { std::unique_lock lk(db_mtx_); inmem_db_.insert_or_assign(k, v); - last_committed_lsn = lsn; ++commit_count_; } @@ -224,10 +223,8 @@ class TestReplicatedDB : public homestore::ReplDevListener { snp_data->is_last_obj); if (snp_data->offset == 0) { - // TODO: this is a workaround to avoid the first snapshot data write error. revisit here and refine - // it. if last_committed_lsn is 0 and we send it back, then the leader will resend this to us, in which the - // snp_data->offset is 0. This will cause the snapshot data write error. So we set it to -1 to avoid this. - snp_data->offset = last_committed_lsn == 0 ? -1 : last_committed_lsn; + auto raft_server = std::dynamic_pointer_cast< RaftReplDev >(repl_dev())->raft_server(); + snp_data->offset = raft_server->get_committed_log_idx(); LOGINFOMOD(replication, "[Replica={}] Save logical snapshot callback return obj_id={}", g_helper->replica_num(), snp_data->offset); return; @@ -250,7 +247,6 @@ class TestReplicatedDB : public homestore::ReplDevListener { value.blkid_ = out_blkids; } inmem_db_.insert_or_assign(key, value); - last_committed_lsn = value.lsn_; ++commit_count_; ptr++; } @@ -372,7 +368,6 @@ class TestReplicatedDB : public homestore::ReplDevListener { std::map< Key, Value > inmem_db_; uint64_t commit_count_{0}; std::shared_mutex db_mtx_; - uint64_t last_committed_lsn{0}; std::shared_ptr< snapshot_context > m_last_snapshot{nullptr}; bool zombie_{false}; };