From a439095697b3e3ec60f1f7d8a0c1ab3ba7b45243 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Mon, 25 Sep 2017 14:14:51 +0900 Subject: [PATCH] clientv3: wait for ConnectNotify before sending RPCs With slow CPU, gRPC can lag behind with RPCs being sent before calling 'Up', returning 'no address available' on the first try. Signed-off-by: Gyu-Ho Lee --- clientv3/retry.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/clientv3/retry.go b/clientv3/retry.go index aab2c9235..e4d1206f7 100644 --- a/clientv3/retry.go +++ b/clientv3/retry.go @@ -51,6 +51,13 @@ func isWriteStopError(err error) bool { func (c *Client) newRetryWrapper(isStop retryStopErrFunc) retryRpcFunc { return func(rpcCtx context.Context, f rpcFunc) error { for { + select { + case <-c.balancer.ConnectNotify(): + case <-rpcCtx.Done(): + return rpcCtx.Err() + case <-c.ctx.Done(): + return c.ctx.Err() + } err := f(rpcCtx) if err == nil { return nil