Skip to content

Commit

Permalink
Add conf condition at the beginning of snapshot_and_compact.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangxiao871 authored and zhangxiao871 committed Aug 2, 2021
1 parent 0ffb76b commit a6b1745
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/handle_commit.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,12 @@ void raft_server::snapshot_and_compact(ulong committed_idx) {
// snapshot is disabled or the log store is not long enough
return;
}
// get the latest configuration info
ptr<cluster_config> conf = get_config();
if ( conf->get_prev_log_idx() >= log_store_->next_slot() ) {
p_in("The latest config and previous config is not in log_store, so skip the snapshot creation");
return;
}
if ( !state_machine_->chk_create_snapshot() ) {
// User-defined state machine doesn't want to create a snapshot.
return;
Expand All @@ -457,8 +463,6 @@ void raft_server::snapshot_and_compact(ulong committed_idx) {
snapshot_in_action = true;
p_in("creating a snapshot for index %llu", committed_idx);

// get the latest configuration info
ptr<cluster_config> conf = get_config();
while ( conf->get_log_idx() > committed_idx &&
conf->get_prev_log_idx() >= log_store_->start_index() ) {
ptr<log_entry> conf_log
Expand Down

0 comments on commit a6b1745

Please sign in to comment.