error: integer divide by zero in picker nextFollower method
akolybelnikov opened this issue · 1 comments
akolybelnikov commented
If len(p.followers) == 0
in Pick it attempts to assign a next follower to the result.SubConn, but the nextFollower
throws an integer divide by zero runtime error because in Go % 0
is division by zero. The error is detectable if you run TestPickerNoSubConnAvailable
.
I am checking for the length and returning nil
early, but checking if strings.Contains(info.FullMethodName, "Produce") || len(p.followers) == 0
loses its meaning in Pick
.
akolybelnikov commented
The actual method includes the following:
if strings.Contains(info.FullMethodName, "Produce") || len(p.followers) == 0 {
result.SubConn = p.leader
} else if strings.Contains(info.FullMethodName, "Consume") {
result.SubConn = p.nextFollower()
}
I have entirely missed the else-if statement. I need to chill...