googleapis/mcp-toolbox · critical
unable to create pool: %w
Error message
unable to create pool: %w
What it means
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.
Source
Thrown at internal/sources/cockroachdb/cockroachdb.go:108
// Observability
EnableTelemetry bool `yaml:"enableTelemetry"` // Default: true
TelemetryVerbose bool `yaml:"telemetryVerbose"` // Default: false
ClusterID string `yaml:"clusterID"` // Optional cluster identifier for telemetry
}
func (r Config) SourceConfigType() string {
return SourceType
}
func (r Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.Source, error) {
retryBaseDelay, err := time.ParseDuration(r.RetryBaseDelay)
if err != nil {
return nil, fmt.Errorf("invalid retryBaseDelay: %w", err)
}
pool, err := initCockroachDBConnectionPoolWithRetry(ctx, tracer, r.Name, r.Host, r.Port, r.User, r.Password, r.Database, r.QueryParams, r.MaxRetries, retryBaseDelay)
if err != nil {
return nil, fmt.Errorf("unable to create pool: %w", err)
}
s := &Source{
Config: r,
Pool: pool,
}
return s, nil
}
var _ sources.Source = &Source{}
type Source struct {
Config
Pool *pgxpool.Pool
}
func (s *Source) IsReadOnly() bool {
return falseView on GitHub (pinned to 8cc6e09de2)
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
Example fix
// before (yaml) host: crdb-internal port: 26257 // after # verified reachable + correct creds host: crdb-internal.example.svc port: 26257 queryParams: sslmode=require
Defensive patterns
Strategy: retry
Validate before calling
// Preflight: raw TCP check before initializing the source
func crdbReachable(host string, port int) error {
conn, err := net.DialTimeout("tcp", fmt.Sprintf("%s:%d", host, port), 3*time.Second)
if err != nil { return err }
return conn.Close()
} Try / catch
src, err := cfg.Initialize(ctx, tracer)
if err != nil {
if strings.Contains(err.Error(), "unable to create pool") {
// check host/port reachability, creds, TLS params, then retry with backoff
time.Sleep(2 * time.Second)
return cfg.Initialize(ctx, tracer)
}
return err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- failed to connect to CockroachDB after %d retries: %w
- sql.Open: %w
- unable to connect successfully: %w
- unable to connect successfully: %w
- unable to initialize source %q: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/b0b8e1ef2f1e7922.
Report an issue: GitHub.