{"record":{"id":"b50a8d4bf006427f","repo":"googleapis/mcp-toolbox","slug":"unable-to-create-pool-w-b50a8d","errorCode":null,"errorMessage":"unable to create pool: %w","messagePattern":"unable to create pool: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/yugabytedb/yugabytedb.go","lineNumber":68,"sourceCode":"\tPort                            string `yaml:\"port\" validate:\"required\"`\n\tUser                            string `yaml:\"user\" validate:\"required\"`\n\tPassword                        string `yaml:\"password\" validate:\"required\"`\n\tDatabase                        string `yaml:\"database\" validate:\"required\"`\n\tLoadBalance                     string `yaml:\"loadBalance\"`\n\tTopologyKeys                    string `yaml:\"topologyKeys\"`\n\tYBServersRefreshInterval        string `yaml:\"ybServersRefreshInterval\"`\n\tFallBackToTopologyKeysOnly      string `yaml:\"fallbackToTopologyKeysOnly\"`\n\tFailedHostReconnectDelaySeconds string `yaml:\"failedHostReconnectDelaySecs\"`\n}\n\nfunc (r Config) SourceConfigType() string {\n\treturn SourceType\n}\n\nfunc (r Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.Source, error) {\n\tpool, err := initYugabyteDBConnectionPool(ctx, tracer, r.Name, r.Host, r.Port, r.User, r.Password, r.Database, r.LoadBalance, r.TopologyKeys, r.YBServersRefreshInterval, r.FallBackToTopologyKeysOnly, r.FailedHostReconnectDelaySeconds)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to create pool: %w\", err)\n\t}\n\n\terr = pool.Ping(ctx)\n\tif err != nil {\n\t\tpool.Close()\n\t\treturn nil, fmt.Errorf(\"unable to connect successfully: %w\", err)\n\t}\n\n\ts := &Source{\n\t\tConfig: r,\n\t\tPool:   pool,\n\t}\n\treturn s, nil\n}\n\nvar _ sources.Source = &Source{}\n\ntype Source struct {","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/yugabytedb/yugabytedb.go#L50-L86","documentation":"The YugabyteDB source's Config.Initialize calls initYugabyteDBConnectionPool to build a pgx connection pool (with Yugabyte load-balancing options). Any error constructing the pool — bad DSN parameters, driver issues, invalid load-balance/topology settings — is wrapped as 'unable to create pool: %w'. The wrapped cause carries the precise reason.","triggerScenarios":"Initialize with invalid connection parameters (host/port/user/password/database), malformed topology_keys or load_balance settings, or an unparseable combination passed to pgxpool config before any connection is attempted.","commonSituations":"Wrong port or hostname in tools.yaml; invalid YAML types (e.g. string where int expected for port/refresh interval); unsupported topology keys syntax; unreachable Yugabyte servers only surfacing later at Ping (error 1028 instead).","solutions":["Verify host, port, user, password, and database values in the source config","Validate load_balance and topology_keys formatting against Yugabyte docs (e.g. 'preload-topology-keys' or 'topology-key=region.zone')","Check numeric fields (yb_servers_refresh_interval, failed_host_reconnect_delay_seconds) are valid integers","Inspect the wrapped '%w' cause in the error message for the exact parse/config failure"],"exampleFix":"// before\nhost: yb-server\nloadBalance: topology=wrong-format\n// after\nhost: yb-server\nloadBalance: true\ntopologyKeys: cloud1.datacenter1.rack1","handlingStrategy":"validation","validationCode":"const required = [\"host\", \"port\", \"user\", \"password\", \"database\"];\nfor (const f of required) {\n  if (cfg[f] === undefined || cfg[f] === \"\") throw new Error(`yugabytedb config missing field: ${f}`);\n}\nif (!Number.isInteger(cfg.port) || cfg.port <= 0) throw new Error(\"port must be a positive integer\");","typeGuard":"function isCompleteYbConfig(c: Partial<YbConfig>): c is YbConfig {\n  return typeof c.host === \"string\" && typeof c.port === \"number\" &&\n    typeof c.user === \"string\" && typeof c.password === \"string\" &&\n    typeof c.database === \"string\";\n}","tryCatchPattern":"try {\n  await startToolbox();\n} catch (err) {\n  if (String(err).includes(\"unable to create pool\")) {\n    console.error(\"Yugabyte pool config invalid; check cause:\", err.cause ?? err.message);\n    process.exit(1);\n  }\n  throw err;\n}","preventionTips":["Validate tools.yaml fields (types and presence) with a schema check before startup","Verify topology_keys/load_balance strings against Yugabyte connection docs","Use ysqlsh with identical parameters to confirm the config works before wiring it up"],"tags":["yugabytedb","postgres","pool","initialization","config"],"backgroundTag":"connection-pool-creation-failed","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}