From 7cc2f8a4114bbc9ca5fe5381504b9c4096fca1ac Mon Sep 17 00:00:00 2001 From: Zhihong Yu Date: Tue, 12 May 2020 16:59:22 -0700 Subject: [PATCH] raft: break out of nested loop when id is found (#11870) Signed-off-by: Ted Yu --- raft/raft.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/raft/raft.go b/raft/raft.go index 25765cf78..3aa645b63 100644 --- a/raft/raft.go +++ b/raft/raft.go @@ -1428,6 +1428,7 @@ func (r *raft) restore(s pb.Snapshot) bool { // code here and there assumes that r.id is in the progress tracker. found := false cs := s.Metadata.ConfState + for _, set := range [][]uint64{ cs.Voters, cs.Learners, @@ -1438,6 +1439,9 @@ func (r *raft) restore(s pb.Snapshot) bool { break } } + if found { + break + } } if !found { r.logger.Warningf(