{"record":{"id":"b0b8e1ef2f1e7922","repo":"googleapis/mcp-toolbox","slug":"unable-to-create-pool-w-b0b8e1","errorCode":null,"errorMessage":"unable to create pool: %w","messagePattern":"unable to create pool: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/sources/cockroachdb/cockroachdb.go","lineNumber":108,"sourceCode":"\t// Observability\n\tEnableTelemetry  bool   `yaml:\"enableTelemetry\"`  // Default: true\n\tTelemetryVerbose bool   `yaml:\"telemetryVerbose\"` // Default: false\n\tClusterID        string `yaml:\"clusterID\"`        // Optional cluster identifier for telemetry\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\tretryBaseDelay, err := time.ParseDuration(r.RetryBaseDelay)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid retryBaseDelay: %w\", err)\n\t}\n\n\tpool, err := initCockroachDBConnectionPoolWithRetry(ctx, tracer, r.Name, r.Host, r.Port, r.User, r.Password, r.Database, r.QueryParams, r.MaxRetries, retryBaseDelay)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to create pool: %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 {\n\tConfig\n\tPool *pgxpool.Pool\n}\n\nfunc (s *Source) IsReadOnly() bool {\n\treturn false","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/cockroachdb/cockroachdb.go#L90-L126","documentation":"CockroachDB source Config.Initialize wraps failures from initCockroachDBConnectionPoolWithRetry as 'unable to create pool'. This means pgx could not establish a working connection pool to the CockroachDB instance after retry attempts — usually unreachable host, bad credentials, TLS problems, or invalid query parameters.","triggerScenarios":"Initialize calls initCockroachDBConnectionPoolWithRetry with host/port/user/password/database/queryParams and maxRetries/baseDelay; the pool creation fails after exhausting retries: wrong host/port, database or user does not exist, password rejected, TLS/mode mismatch, or malformed query params in the connection string.","commonSituations":"CockroachDB cluster not yet running or cloud instance paused, firewall/VPC blocking the SQL port (26257), expired/rotated password in config, connecting with sslmode requirements the client config doesn't satisfy, DNS failures in containers.","solutions":["Verify connectivity: cockroach sql --url 'postgres://user:pass@host:26257/db' or nc -vz host 26257","Check host, port, user, password, and database values in the source config for typos or stale secrets","Confirm TLS settings/query params match the cluster's requirements (e.g. sslmode, root cert)","Ensure the CockroachDB instance is running and reachable from the toolbox's network","Increase MaxRetries / RetryBaseDelay if the failure is transient startup ordering"],"exampleFix":"// before (yaml)\nhost: crdb-internal\nport: 26257\n// after  # verified reachable + correct creds\nhost: crdb-internal.example.svc\nport: 26257\nqueryParams: sslmode=require","handlingStrategy":"retry","validationCode":"// Preflight: raw TCP check before initializing the source\nfunc crdbReachable(host string, port int) error {\n    conn, err := net.DialTimeout(\"tcp\", fmt.Sprintf(\"%s:%d\", host, port), 3*time.Second)\n    if err != nil { return err }\n    return conn.Close()\n}","typeGuard":null,"tryCatchPattern":"src, err := cfg.Initialize(ctx, tracer)\nif err != nil {\n    if strings.Contains(err.Error(), \"unable to create pool\") {\n        // check host/port reachability, creds, TLS params, then retry with backoff\n        time.Sleep(2 * time.Second)\n        return cfg.Initialize(ctx, tracer)\n    }\n    return err\n}","preventionTips":["Verify connectivity with cockroach sql or a TCP dial before starting the toolbox","Store DB credentials in a secret manager and rotate-aware refresh rather than hardcoded config","Match sslmode/query params to the cluster's TLS requirements","Size MaxRetries/RetryBaseDelay to tolerate startup ordering in orchestrated deployments"],"tags":["cockroachdb","connection","pool","database","wrap-error"],"backgroundTag":"database-connection-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"}