Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
On condition consensus-level 0, updating slave binlog sync info may 
lead to coredump.
  • Loading branch information
whoiami authored May 25, 2020
1 parent d6d1898 commit 28267f1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/pika_consensus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ Status SyncProgress::Update(const std::string& ip, int port, const LogOffset& st
match_index_[ip+std::to_string(port)] = acked_offset;
}

// if consensus_level == 0 LogOffset() return
*committed_index = InternalCalCommittedIndex(GetAllMatchIndex());
return Status::OK();
}
Expand All @@ -180,6 +181,9 @@ int SyncProgress::SlaveSize() {

LogOffset SyncProgress::InternalCalCommittedIndex(std::unordered_map<std::string, LogOffset> match_index) {
int consensus_level = g_pika_conf->consensus_level();
if (consensus_level == 0) {
return LogOffset();
}
if (static_cast<int>(match_index.size()) < consensus_level) {
return LogOffset();
}
Expand Down

0 comments on commit 28267f1

Please sign in to comment.