Skip to content

Commit

Permalink
Fix flaky leader index in waitLeader function
Browse files Browse the repository at this point in the history
Signed-off-by: Xinyuan Du <[email protected]>
  • Loading branch information
MrDXY committed Mar 21, 2024
1 parent e1bfcf7 commit 387d8b0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rafttest/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func TestPause(t *testing.T) {

func waitLeader(ns []*node) int {
var l map[uint64]struct{}
var lindex int
var lindex = -1

for {
l = make(map[uint64]struct{})
Expand All @@ -144,7 +144,7 @@ func waitLeader(ns []*node) int {
}
}

if len(l) == 1 {
if len(l) == 1 && lindex != -1 {
return lindex
}
}
Expand Down

0 comments on commit 387d8b0

Please sign in to comment.