{"record":{"id":"f3b49aa61b616468","repo":"redis/go-redis","slug":"redis-failed-to-create-connection-pool-w-f3b49a","errorCode":null,"errorMessage":"redis: failed to create connection pool: %w","messagePattern":"redis: failed to create connection pool: %w","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"sentinel.go","lineNumber":593,"sourceCode":"\t\t\tonClose:  &onCloseHooks{},\n\t\t\thimport:  newHImportRegistry(),\n\t\t},\n\t}\n\trdb.init()\n\n\t// Initialize push notification processor using shared helper\n\t// Use void processor by default for RESP2 connections\n\trdb.pushProcessor = initializePushProcessor(opt)\n\n\t// Generate unique pool names for metrics\n\tuniqueID := generateUniqueID()\n\tmainPoolName := opt.Addr + \"_\" + uniqueID\n\tpubsubPoolName := opt.Addr + \"_\" + uniqueID + \"_pubsub\"\n\n\tvar err error\n\trdb.connPool, err = newConnPool(opt, rdb.dialHook, mainPoolName)\n\tif err != nil {\n\t\tpanic(fmt.Errorf(\"redis: failed to create connection pool: %w\", err))\n\t}\n\trdb.pubSubPool, err = newPubSubPool(opt, rdb.dialHook, pubsubPoolName)\n\tif err != nil {\n\t\tpanic(fmt.Errorf(\"redis: failed to create pubsub pool: %w\", err))\n\t}\n\n\t// Create the dedicated pipeline pool unconditionally, mirroring NewClient\n\t// via the shared buildPipelinePool helper. PipelinePoolSize < 0 opts out.\n\tif opt.PipelinePoolSize >= 0 {\n\t\tref, err := rdb.buildPipelinePool(mainPoolName + \"_pipeline\")\n\t\tif err != nil {\n\t\t\tpanic(fmt.Errorf(\"redis: failed to create pipeline connection pool: %w\", err))\n\t\t}\n\t\trdb.pipelinePool = ref\n\t}\n\n\t// Register pools for OTel async gauge metrics, matching NewClient (the\n\t// failover client previously registered none, so pool gauges were silent","sourceCodeStart":575,"sourceCodeEnd":611,"githubUrl":"https://github.com/redis/go-redis/blob/c5cad058c72f58370553b48566302303cf8a2e89/sentinel.go#L575-L611","documentation":"NewFailoverClient dials nothing itself, but it does build the local connection pool. If pool construction (newConnPool) fails, the client panics, wrapping the underlying error with this message. Because pools allocate buffers/resources eagerly, failure here usually indicates invalid pool configuration rather than a network problem.","triggerScenarios":"Calling NewFailoverClient (or NewUniversalClient with sentinel options) with options that make newConnPool fail — e.g. an invalid Dialer, nil/broken Dialer with custom settings, or hook/pool configuration that errors at setup.","commonSituations":"Programmatic construction of FailoverOptions with fields that bypass URL validation, misconfigured custom dialers in tests, or options produced by merging configs where the pool setup becomes invalid.","solutions":["Recover the panic and inspect the wrapped error (%w) to find the root cause","Validate FailoverOptions before construction (Dialer set, sane PoolSize/MinIdleConns)","If constructing via URL, run ParseFailoverURL first so invalid values are rejected as errors instead of panics"],"exampleFix":"// before\nrdb := redis.NewFailoverClient(opt) // panics on bad pool config\n// after\nif opt.Dialer == nil && opt.Addr == \"\" { return fmt.Errorf(\"missing dialer\") }\nrdb := redis.NewFailoverClient(opt)","handlingStrategy":"try-catch","validationCode":"if opt == nil { return errors.New(\"nil FailoverOptions\") }\nif opt.Dialer == nil && len(opt.SentinelAddrs) == 0 { return errors.New(\"no dialer or sentinel addrs\") }","typeGuard":null,"tryCatchPattern":"func newFailoverSafe(opt *redis.FailoverOptions) (rdb *redis.Client, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"NewFailoverClient: %v\", r)\n        }\n    }()\n    rdb = redis.NewFailoverClient(opt)\n    return rdb, nil\n}","preventionTips":["Build options via ParseFailoverURL to get error returns instead of panics","Validate pool-related options (PoolSize, MinIdleConns, Dialer) before construction","Wrap client construction in a recover helper at app startup"],"tags":["redis","sentinel","connection-pool","panic"],"backgroundTag":"connection-pool-creation-failed","analyzedSha":"c5cad058c72f58370553b48566302303cf8a2e89","analyzedAt":"2026-09-01T06:50:53.388Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}