Skip to content

Commit

Permalink
client: Work around tight loop when retrying watch connection.
Browse files Browse the repository at this point in the history
Add a 100ms sleep to avoid tight loop if reconnection fails quickly.

Fixes #9578
  • Loading branch information
fasaxc committed Apr 24, 2018
1 parent 3da4c8a commit 77c80d3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions clientv3/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,15 @@ func (w *watchGrpcStream) openWatchClient() (ws pb.Watch_WatchClient, err error)
if isHaltErr(w.ctx, err) {
return nil, v3rpc.Error(err)
}
select {
case <- time.After(100 * time.Millisecond):
continue
case <- w.ctx.Done():
if err == nil {
return nil, w.ctx.Err()
}
return nil, err
}
}
return ws, nil
}
Expand Down

0 comments on commit 77c80d3

Please sign in to comment.