Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonYao287 committed Aug 28, 2024
1 parent a42a684 commit 6b10cae
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/tests/test_raft_repl_dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class TestReplicatedDB : public homestore::ReplDevListener {
sisl::io_blob_safe blob{static_cast< uint32_t >(kv_snapshot_data_size)};
std::memcpy(blob.bytes(), kv_snapshot_data.data(), kv_snapshot_data_size);
snp_data->blob = std::move(blob);
snp_data->is_last_obj = false;
snp_data->is_last_obj = true;
LOGINFOMOD(replication, "[Replica={}] Read logical snapshot callback obj_id={} term={} idx={} num_items={}",
g_helper->replica_num(), snp_data->offset, s->get_last_log_term(), s->get_last_log_idx(),
kv_snapshot_data.size());
Expand All @@ -230,9 +230,10 @@ class TestReplicatedDB : public homestore::ReplDevListener {

void write_snapshot_data(shared< snapshot_context > context, shared< snapshot_data > snp_data) override {
auto s = std::dynamic_pointer_cast< nuraft_snapshot_context >(context)->nuraft_snapshot();
auto raft_server = std::dynamic_pointer_cast< RaftReplDev >(repl_dev())->raft_server();
auto last_committed_idx =
std::dynamic_pointer_cast< RaftReplDev >(repl_dev())->raft_server()->get_committed_log_idx();
if (snp_data->offset == 0) {
snp_data->offset = raft_server->get_committed_log_idx();
snp_data->offset = last_committed_idx + 1;
LOGINFOMOD(replication, "[Replica={}] Save logical snapshot callback return obj_id={}",
g_helper->replica_num(), snp_data->offset);
return;
Expand Down Expand Up @@ -265,7 +266,7 @@ class TestReplicatedDB : public homestore::ReplDevListener {
"[Replica={}] Save logical snapshot callback obj_id={} term={} idx={} is_last={} num_items={}",
g_helper->replica_num(), snp_data->offset, s->get_last_log_term(), s->get_last_log_idx(),
snp_data->is_last_obj, num_items);
snp_data->offset = raft_server->get_committed_log_idx() + 1;
snp_data->offset = last_committed_idx + 1;
}

bool apply_snapshot(shared< snapshot_context > context) override {
Expand Down

0 comments on commit 6b10cae

Please sign in to comment.