Skip to content

Commit

Permalink
Fix NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
JackyWoo committed Nov 10, 2023
1 parent ac65d82 commit 2c3d742
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Service/NuRaftStateMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ NuRaftStateMachine::NuRaftStateMachine(
LOG_INFO(log, "Loading logs from {} to {}", last_committed_idx + 1, previous_last_commit_id);
replayLogs(log_store_, last_committed_idx + 1, previous_last_commit_id);

/// In order to meet the initial application of snapshot in the cluster.
/// At this time, the log index is less than the last index of the snapshot, and compact is required.
if (log_store_->next_slot() <= last_committed_idx)
/// If the node is empty and join cluster, the log index is less than the last index of the snapshot, so compact is required.
if (log_store_ && log_store_->next_slot() <= last_committed_idx)
log_store_->compact(last_committed_idx);

LOG_INFO(log, "Starting background creating snapshot thread.");
Expand Down

0 comments on commit 2c3d742

Please sign in to comment.