From 2c2e8f23c74cc46c4b10f2f3addb38ccdb5e68e9 Mon Sep 17 00:00:00 2001 From: JohnnyThree Date: Mon, 28 Dec 2020 21:19:23 +0800 Subject: [PATCH] fix meta data related operation hang when zk down Signed-off-by: JohnnyThree --- go/vt/topo/zk2topo/zk_conn.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/go/vt/topo/zk2topo/zk_conn.go b/go/vt/topo/zk2topo/zk_conn.go index 7936c6f77c9..b0d80510968 100644 --- a/go/vt/topo/zk2topo/zk_conn.go +++ b/go/vt/topo/zk2topo/zk_conn.go @@ -341,6 +341,8 @@ func (c *ZkConn) handleSessionEvents(conn *zk.Conn, session <-chan zk.Event) { func dialZk(ctx context.Context, addr string) (*zk.Conn, <-chan zk.Event, error) { servers := strings.Split(addr, ",") dialer := zk.WithDialer(net.DialTimeout) + ctx, cancel := context.WithTimeout(ctx, *baseTimeout) + defer cancel() // If TLS is enabled use a TLS enabled dialer option if *certPath != "" && *keyPath != "" { if strings.Contains(addr, ",") {