Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonYao287 committed Sep 10, 2024
1 parent f6108de commit 5d241e6
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/tests/test_raft_repl_dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,20 +204,20 @@ class TestReplicatedDB : public homestore::ReplDevListener {
if (kv_snapshot_data.size() >= 1000) { break; }
}

if (kv_snapshot_data.size()) {
int64_t kv_snapshot_data_size = sizeof(KeyValuePair) * kv_snapshot_data.size();
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);
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());
} else {
LOGINFOMOD(replication, "no data need to be sent for snapshot");
if (kv_snapshot_data.size() == 0) {
snp_data->is_last_obj = true;
LOGINFOMOD(replication, "Snapshot is_last_obj is true");
return 0;
}

// we always read all the data in one shot, so we need to set is_last_obj to true
snp_data->is_last_obj = true;
int64_t kv_snapshot_data_size = sizeof(KeyValuePair) * kv_snapshot_data.size();
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;
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());

return 0;
}
Expand Down Expand Up @@ -272,8 +272,6 @@ class TestReplicatedDB : public homestore::ReplDevListener {

// before we finish install snapshot, raft_server()->get_committed_log_idx() will always be the same. so we need
// last_data_committed_lsn to notify leader to transfer new data to follower.
// actually, leader will transfer all the data in one shot, so this is will not trigger any error, but we should
// make the logic correct.
snp_data->offset = last_data_committed_lsn + 1;
}

Expand Down

0 comments on commit 5d241e6

Please sign in to comment.