{"record":{"id":"e51461df34c9d844","repo":"redis/go-redis","slug":"redis-failed-to-create-pubsub-pool-w","errorCode":null,"errorMessage":"redis: failed to create pubsub pool: %w","messagePattern":"redis: failed to create pubsub pool: %w","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"redis.go","lineNumber":2120,"sourceCode":"\t// Use void processor for RESP2 connections (push notifications not available)\n\tc.pushProcessor = initializePushProcessor(opt)\n\t// set opt push processor for child clients\n\tc.opt.PushNotificationProcessor = c.pushProcessor\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\t// Create connection pools\n\tvar err error\n\tc.connPool, err = newConnPool(opt, c.dialHook, mainPoolName)\n\tif err != nil {\n\t\tpanic(fmt.Errorf(\"redis: failed to create connection pool: %w\", err))\n\t}\n\tc.pubSubPool, err = newPubSubPool(opt, c.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, like pubSubPool: it\n\t// is pure burst capacity (no pre-dialing, small cap, larger buffers — see\n\t// pipelinePoolOptions), so an unused pipeline pool holds zero connections\n\t// and costs nothing. Pipelines stop competing with regular commands for\n\t// main-pool connections; a burst wider than the pool's cap spills back to\n\t// the main pool (see withPipelineConn). PipelinePoolSize < 0 opts out.\n\tif opt.PipelinePoolSize >= 0 {\n\t\tref, err := c.buildPipelinePool(opt.Addr + \"_\" + uniqueID + \"_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\tc.pipelinePool = ref\n\t}\n\n\tif opt.StreamingCredentialsProvider != nil {\n\t\tc.streamingCredentialsManager = streaming.NewManager(c.connPool, c.opt.PoolTimeout)","sourceCodeStart":2102,"sourceCodeEnd":2138,"githubUrl":"https://github.com/redis/go-redis/blob/c5cad058c72f58370553b48566302303cf8a2e89/redis.go#L2102-L2138","documentation":"Raised when constructing the dedicated PubSub connection pool during client creation fails. Like the main pool, failure means an invalid pool configuration rather than a network problem. NewClient panics because the client would be unusable without its pubsub pool.","triggerScenarios":"redis.NewClient with Options that make newPubSubPool fail (invalid pool sizing/buffer options affecting the pubsub pool), at redis.go:2120.","commonSituations":"The same invalid Options that break the main pool usually hit here right after error 200 — e.g. invalid ReadBufferSize/WriteBufferSize or negative size fields; building Options from unvalidated config files.","solutions":["Inspect the wrapped inner error to identify the bad option","Correct the invalid redis.Options field used for the pubsub pool","If pubsub is unused, still fix Options — the pool is created unconditionally"],"exampleFix":"// before\nredis.NewClient(&redis.Options{Addr: addr, ReadBufferSize: -1})\n// after\nredis.NewClient(&redis.Options{Addr: addr}) // let the library use defaults","handlingStrategy":"validation","validationCode":"if opt.ReadBufferSize < 0 || opt.WriteBufferSize < 0 { return errors.New(\"buffer sizes must be non-negative\") }\nclient := redis.NewClient(opt)","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        err = fmt.Errorf(\"redis client init failed: %v\", r)\n    }\n}()","preventionTips":["Do not set buffer/pool fields unless you have a specific reason","Validate Options struct with a helper before constructing any client","Log the full Options (minus credentials) when initialization panics"],"tags":["go","client-init","panic","pubsub"],"backgroundTag":"invalid-pool-configuration","analyzedSha":"c5cad058c72f58370553b48566302303cf8a2e89","analyzedAt":"2026-09-01T06:50:53.388Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}