From ad16b21487a2dbc68e658a381a69728f4a5efe45 Mon Sep 17 00:00:00 2001 From: Nedyalko Dyakov Date: Fri, 27 Jun 2025 13:41:30 +0300 Subject: [PATCH] fix: initialize push notification processor in NewFailoverClient - Add push processor initialization to NewFailoverClient to prevent nil pointer dereference - Use VoidPushNotificationProcessor for failover clients (typically don't need push notifications) - Ensure consistent behavior across all client creation paths including failover scenarios - Complete the coverage of all client types that inherit from baseClient This fixes the final nil pointer dereference that was occurring in failover client contexts where the pushProcessor field was nil, causing segmentation violations during Redis operations in sentinel-managed failover scenarios. --- sentinel.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sentinel.go b/sentinel.go index 61494d72..df5742a3 100644 --- a/sentinel.go +++ b/sentinel.go @@ -426,6 +426,14 @@ func NewFailoverClient(failoverOpt *FailoverOptions) *Client { } rdb.init() + // Initialize push notification processor to prevent nil pointer dereference + if opt.PushNotificationProcessor != nil { + rdb.pushProcessor = opt.PushNotificationProcessor + } else { + // Create void processor for failover client (typically doesn't need push notifications) + rdb.pushProcessor = NewVoidPushNotificationProcessor() + } + connPool = newConnPool(opt, rdb.dialHook) rdb.connPool = connPool rdb.onClose = rdb.wrappedOnClose(failover.Close)