raft: don't campaign with pending snapshot (#12163)

Signed-off-by: Jay Lee <BusyJayLee@gmail.com>
This commit is contained in:
Jay
2020-07-26 15:04:46 +08:00
committed by GitHub
parent c9a5889915
commit 26b89fd418
4 changed files with 48 additions and 15 deletions

View File

@@ -157,7 +157,7 @@ func (rn *RawNode) HasReady() bool {
if hardSt := r.hardState(); !IsEmptyHardState(hardSt) && !isHardStateEqual(hardSt, rn.prevHardSt) {
return true
}
if r.raftLog.unstable.snapshot != nil && !IsEmptySnap(*r.raftLog.unstable.snapshot) {
if r.raftLog.hasPendingSnapshot() {
return true
}
if len(r.msgs) > 0 || len(r.raftLog.unstableEntries()) > 0 || r.raftLog.hasNextEnts() {