66 "time"
77
88 "github.com/redis/go-redis/v9/internal"
9- "github.com/redis/go-redis/v9/internal/interfaces"
109 "github.com/redis/go-redis/v9/internal/pool"
1110 "github.com/redis/go-redis/v9/push"
1211)
@@ -107,6 +106,10 @@ func (snh *NotificationHandler) handleMoving(ctx context.Context, handlerCtx pus
107106 deadline := time .Now ().Add (time .Duration (timeS ) * time .Second )
108107 // If newEndpoint is empty, we should schedule a handoff to the current endpoint in timeS/2 seconds
109108 if newEndpoint == "" || newEndpoint == internal .RedisNull {
109+ if snh .manager .config .LogLevel >= 3 { // Debug level
110+ internal .Logger .Printf (ctx , "hitless: conn[%d] scheduling handoff to current endpoint in %v seconds" ,
111+ poolConn .GetID (), timeS / 2 )
112+ }
110113 // same as current endpoint
111114 newEndpoint = snh .manager .options .GetAddr ()
112115 // delay the handoff for timeS/2 seconds to the same endpoint
@@ -137,7 +140,6 @@ func (snh *NotificationHandler) markConnForHandoff(conn *pool.Conn, newEndpoint
137140 // Optionally track in hitless manager for monitoring/debugging
138141 if snh .manager != nil {
139142 connID := conn .GetID ()
140-
141143 // Track the operation (ignore errors since this is optional)
142144 _ = snh .manager .TrackMovingOperationWithConnID (context .Background (), newEndpoint , deadline , seqID , connID )
143145 } else {
@@ -160,14 +162,18 @@ func (snh *NotificationHandler) handleMigrating(ctx context.Context, handlerCtx
160162 return ErrInvalidNotification
161163 }
162164
163- connAdapter , ok := handlerCtx .Conn .(interfaces. ConnectionWithRelaxedTimeout )
165+ conn , ok := handlerCtx .Conn .(* pool. Conn )
164166 if ! ok {
165167 internal .Logger .Printf (ctx , "hitless: invalid connection type in handler context for MIGRATING notification" )
166168 return ErrInvalidNotification
167169 }
168170
169171 // Apply relaxed timeout to this specific connection
170- connAdapter .SetRelaxedTimeout (snh .manager .config .RelaxedTimeout , snh .manager .config .RelaxedTimeout )
172+ if snh .manager .config .LogLevel >= 3 { // Debug level
173+ internal .Logger .Printf (ctx , "hitless: conn[%d] applying relaxed timeout (%v) for MIGRATING notification" ,
174+ snh .manager .config .RelaxedTimeout , conn .GetID ())
175+ }
176+ conn .SetRelaxedTimeout (snh .manager .config .RelaxedTimeout , snh .manager .config .RelaxedTimeout )
171177 return nil
172178}
173179
@@ -185,14 +191,18 @@ func (snh *NotificationHandler) handleMigrated(ctx context.Context, handlerCtx p
185191 return ErrInvalidNotification
186192 }
187193
188- connAdapter , ok := handlerCtx .Conn .(interfaces. ConnectionWithRelaxedTimeout )
194+ conn , ok := handlerCtx .Conn .(* pool. Conn )
189195 if ! ok {
190196 internal .Logger .Printf (ctx , "hitless: invalid connection type in handler context for MIGRATED notification" )
191197 return ErrInvalidNotification
192198 }
193199
194200 // Clear relaxed timeout for this specific connection
195- connAdapter .ClearRelaxedTimeout ()
201+ if snh .manager .config .LogLevel >= 3 { // Debug level
202+ connID := conn .GetID ()
203+ internal .Logger .Printf (ctx , "hitless: conn[%d] clearing relaxed timeout for MIGRATED notification" , connID )
204+ }
205+ conn .ClearRelaxedTimeout ()
196206 return nil
197207}
198208
@@ -210,14 +220,18 @@ func (snh *NotificationHandler) handleFailingOver(ctx context.Context, handlerCt
210220 return ErrInvalidNotification
211221 }
212222
213- connAdapter , ok := handlerCtx .Conn .(interfaces. ConnectionWithRelaxedTimeout )
223+ conn , ok := handlerCtx .Conn .(* pool. Conn )
214224 if ! ok {
215225 internal .Logger .Printf (ctx , "hitless: invalid connection type in handler context for FAILING_OVER notification" )
216226 return ErrInvalidNotification
217227 }
218228
219229 // Apply relaxed timeout to this specific connection
220- connAdapter .SetRelaxedTimeout (snh .manager .config .RelaxedTimeout , snh .manager .config .RelaxedTimeout )
230+ if snh .manager .config .LogLevel >= 3 { // Debug level
231+ connID := conn .GetID ()
232+ internal .Logger .Printf (ctx , "hitless: conn[%d] applying relaxed timeout (%v) for FAILING_OVER notification" , connID , snh .manager .config .RelaxedTimeout )
233+ }
234+ conn .SetRelaxedTimeout (snh .manager .config .RelaxedTimeout , snh .manager .config .RelaxedTimeout )
221235 return nil
222236}
223237
@@ -235,13 +249,17 @@ func (snh *NotificationHandler) handleFailedOver(ctx context.Context, handlerCtx
235249 return ErrInvalidNotification
236250 }
237251
238- connAdapter , ok := handlerCtx .Conn .(interfaces. ConnectionWithRelaxedTimeout )
252+ conn , ok := handlerCtx .Conn .(* pool. Conn )
239253 if ! ok {
240254 internal .Logger .Printf (ctx , "hitless: invalid connection type in handler context for FAILED_OVER notification" )
241255 return ErrInvalidNotification
242256 }
243257
244258 // Clear relaxed timeout for this specific connection
245- connAdapter .ClearRelaxedTimeout ()
259+ if snh .manager .config .LogLevel >= 3 { // Debug level
260+ connID := conn .GetID ()
261+ internal .Logger .Printf (ctx , "hitless: conn[%d] clearing relaxed timeout for FAILED_OVER notification" , connID )
262+ }
263+ conn .ClearRelaxedTimeout ()
246264 return nil
247265}
0 commit comments