{"record":{"id":"6ec57334899df314","repo":"t8y2/dbx","slug":"connect-to-zookeeper-w-6ec573","errorCode":null,"errorMessage":"connect to ZooKeeper: %w","messagePattern":"connect to ZooKeeper: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/hive-go/discovery.go","lineNumber":106,"sourceCode":"\t\t\t\tdialer := &net.Dialer{Timeout: dialTimeout}\n\t\t\t\treturn tls.DialWithDialer(dialer, network, address, config)\n\t\t\t}),\n\t\t)\n\t}\n}\n\nfunc (discovery *zooKeeperDiscovery) Endpoints(ctx context.Context, rejected map[string]bool) ([]endpoint, error) {\n\taddresses := make([]string, 0, len(discovery.servers))\n\tfor _, server := range discovery.servers {\n\t\taddresses = append(addresses, server.address())\n\t}\n\ttimeout := discovery.timeout\n\tif timeout <= 0 {\n\t\ttimeout = defaultConnectTimeout\n\t}\n\tconnection, events, err := discovery.dialer(addresses, timeout)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"connect to ZooKeeper: %w\", err)\n\t}\n\tdefer connection.Close()\n\tif err := waitForZooKeeperSession(ctx, events, timeout); err != nil {\n\t\treturn nil, err\n\t}\n\tif discovery.authScheme != \"\" || discovery.auth != \"\" {\n\t\tif discovery.authScheme == \"\" || discovery.auth == \"\" {\n\t\t\treturn nil, errors.New(\"ZooKeeper auth scheme and credentials must be configured together\")\n\t\t}\n\t\tif err := connection.AddAuth(discovery.authScheme, []byte(discovery.auth)); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"authenticate to ZooKeeper: %w\", err)\n\t\t}\n\t}\n\tresolved := make([]endpoint, 0)\n\tvar listedPath string\n\tvar nodeFailures []string\n\tfor _, path := range discovery.paths() {\n\t\tchildren, _, childrenErr := connection.Children(path)","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/hive-go/discovery.go#L88-L124","documentation":"This error wraps the ZooKeeper dialer failure in discovery.Endpoints (discovery.go:106). Before querying HiveServer2 endpoints from ZooKeeper, the driver connects to the ZooKeeper ensemble; if that connection cannot be established within the timeout, this error is returned with the underlying cause.","triggerScenarios":"discovery.dialer(addresses, timeout) fails: ZooKeeper hosts unreachable, wrong zk quorum addresses, DNS failure, or the connection exceeds the configured/default timeout.","commonSituations":"Wrong ZooKeeper host list in the connection string; zk port 2181 blocked by firewall; ZooKeeper ensemble down or in election; DNS name for zk hosts unresolvable from the client environment.","solutions":["Verify the ZooKeeper host:port list in the configuration is correct and resolvable.","Test network reachability to the zk quorum (telnet/nc host 2181).","Increase the ZooKeeper connect timeout if the ensemble is slow to respond.","Check ZooKeeper ensemble health (status via zkServer.sh status)."],"exampleFix":"// before\ndsn := \"hive://user:pass@host:10000/db?zookeeper=zk-internal:2181\"\n// after\ndsn := \"hive://user:pass@host:10000/db?zookeeper=zk1:2181,zk2:2181,zk3:2181&connectTimeout=30s\"","handlingStrategy":"try-catch","validationCode":"for _, zk := range strings.Split(zkHosts, \",\") {\n    conn, err := net.DialTimeout(\"tcp\", zk, 3*time.Second)\n    if err != nil {\n        return fmt.Errorf(\"zookeeper unreachable before connect: %s\", zk)\n    }\n    conn.Close()\n}\n","typeGuard":null,"tryCatchPattern":"endpoints, err := discovery.Endpoints(ctx)\nvar zkErr error\nif errors.As(err, &zkErr) || strings.Contains(err.Error(), \"connect to ZooKeeper\") {\n    // check zk quorum reachability, then retry with backoff\n    return retryWithBackoff(ctx, 3, func() error { _, err := discovery.Endpoints(ctx); return err })\n}\n","preventionTips":["Configure multiple ZooKeeper servers for quorum redundancy.","Pre-check zk host:port reachability before initializing the driver.","Set an explicit connect timeout appropriate for your network.","Monitor ZooKeeper ensemble health with zkServer status alerts."],"tags":["zookeeper","network","connection","go"],"backgroundTag":"zookeeper-connect-failed","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}