File tree 1 file changed +11
-1
lines changed
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -312,7 +312,17 @@ func (c *baseClient) onAuthenticationErr(poolCn *pool.Conn) func(err error) {
312
312
return func (err error ) {
313
313
if err != nil {
314
314
if isBadConn (err , false , c .opt .Addr ) {
315
- c .connPool .CloseConn (poolCn )
315
+ // Close the connection to force a reconnection.
316
+ err := c .connPool .CloseConn (poolCn )
317
+ if err != nil {
318
+ internal .Logger .Printf (context .Background (), "redis: failed to close connection: %v" , err )
319
+ // try to close the network connection directly
320
+ // so that no resource is leaked
321
+ err := poolCn .Close ()
322
+ if err != nil {
323
+ internal .Logger .Printf (context .Background (), "redis: failed to close network connection: %v" , err )
324
+ }
325
+ }
316
326
}
317
327
internal .Logger .Printf (context .Background (), "redis: re-authentication failed: %v" , err )
318
328
}
You can’t perform that action at this time.
0 commit comments