Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwmao committed Dec 3, 2024
1 parent fb3461f commit 4b81c3f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/lib/replication/repl_dev/raft_repl_dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,7 @@ void RaftReplDev::create_snp_resync_data(raft_buf_ptr_t& data_out) {
snp_repl_dev_data msg;
auto msg_size = sizeof(snp_repl_dev_data);
msg.dsn = m_next_dsn;
auto crc = crc32_ieee(0, reinterpret_cast< const unsigned char* >(&msg), msg_size);
auto crc = crc32_ieee(init_crc32, reinterpret_cast< const unsigned char* >(&msg), msg_size);
RD_LOGD("create snapshot resync msg, dsn={}, crc={}", msg.dsn, crc);
msg.crc = crc;
data_out = nuraft::buffer::alloc(msg_size);
Expand All @@ -1512,7 +1512,7 @@ bool RaftReplDev::apply_snp_resync_data(nuraft::buffer& data) {
auto received_crc = msg->crc;
RD_LOGD("received snapshot resync msg, dsn={}, crc={}, received crc={}", msg->dsn, msg->crc, received_crc);
msg->crc = 0;
auto computed_crc = crc32_ieee(0, reinterpret_cast< const unsigned char* >(msg),
auto computed_crc = crc32_ieee(init_crc32, reinterpret_cast< const unsigned char* >(msg),
sizeof(snp_repl_dev_data));
if (received_crc != computed_crc) {
RD_LOGE("Snapshot resync data crc mismatch, received_crc={}, computed_crc={}", received_crc, computed_crc);
Expand Down
6 changes: 3 additions & 3 deletions src/lib/replication/repl_dev/raft_state_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ int RaftStateMachine::read_logical_snp_obj(nuraft::snapshot& s, void*& user_ctx,
bool& is_last_obj) {
// For Nuraft baseline resync, we separate the process into two layers: HomeStore layer and Application layer.
// We use the highest bit of the obj_id to indicate the message type: 0 is for HS, 1 is for Application.
if ((obj_id & snp_obj_id_type_mask) == 0) {
if (is_hs_snp_obj(obj_id)) {
// This is the preserved msg for homestore to resync data
m_rd.create_snp_resync_data(data_out);
is_last_obj = false;
Expand Down Expand Up @@ -328,7 +328,7 @@ int RaftStateMachine::read_logical_snp_obj(nuraft::snapshot& s, void*& user_ctx,

void RaftStateMachine::save_logical_snp_obj(nuraft::snapshot& s, ulong& obj_id, nuraft::buffer& data, bool is_first_obj,
bool is_last_obj) {
if ((obj_id & snp_obj_id_type_mask) == 0) {
if (is_hs_snp_obj(obj_id)) {
// Homestore preserved msg
if (m_rd.apply_snp_resync_data(data)) {
obj_id = snp_obj_id_type_mask;
Expand Down Expand Up @@ -367,7 +367,7 @@ bool RaftStateMachine::apply_snapshot(nuraft::snapshot& s) {
auto snp_ctx = std::make_shared< nuraft_snapshot_context >(s);
auto res = m_rd.m_listener->apply_snapshot(snp_ctx);
//make sure the changes are flushed.
hs()->cp_mgr().trigger_cp_flush(true /* force */);
hs()->cp_mgr().trigger_cp_flush(true /* force */).get();
return res;
}

Expand Down
2 changes: 2 additions & 0 deletions src/lib/replication/repl_dev/raft_state_machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ class RaftStateMachine : public nuraft::state_machine {

std::string rdev_name() const;

bool is_hs_snp_obj(uint64_t obj_id) const { return (obj_id & snp_obj_id_type_mask) == 0; }

private:
void after_precommit_in_leader(const nuraft::raft_server::req_ext_cb_params& params);
};
Expand Down

0 comments on commit 4b81c3f

Please sign in to comment.