fix retrying waiting for a leader on stream leader evict
@@ -480,8 +480,8 @@ func (c *streamCmd) leaderStandDown(_ *fisk.ParseContext) error {
ctr := 0
start := time.Now()
- for range time.NewTimer(500 * time.Millisecond).C {
- if ctr == 5 {
+ for range time.NewTicker(1 * time.Millisecond).C {
+ if ctr == 10 {
return fmt.Errorf("stream did not elect a new leader in time")
}
ctr++
@@ -492,6 +492,11 @@ func (c *streamCmd) leaderStandDown(_ *fisk.ParseContext) error {
continue
}
+ if info.Cluster.Leader == "" {
+ log.Printf("No leader elected")
+ continue
+ }
+
if info.Cluster.Leader != leader {
log.Printf("New leader elected %q", info.Cluster.Leader)
break
