@@ -449,12 +449,19 @@ func (ph *PoolHook) performConnectionHandoffWithPool(ctx context.Context, conn *
449449 }
450450 err := ErrMaxHandoffRetriesReached
451451 if pooler != nil {
452- pooler .Remove (ctx , conn , err )
452+ go pooler .Remove (ctx , conn , err )
453+ if ph .config != nil && ph .config .LogLevel >= 1 { // Warning level
454+ internal .Logger .Printf (ctx ,
455+ "hitless: removed connection %d from pool due to max handoff retries reached" ,
456+ conn .GetID ())
457+ }
453458 } else {
454- conn .Close ()
455- internal .Logger .Printf (ctx ,
456- "hitless: no pool provided for connection %d, cannot remove due to handoff initialization failure: %v" ,
457- conn .GetID (), err )
459+ go conn .Close ()
460+ if ph .config != nil && ph .config .LogLevel >= 1 { // Warning level
461+ internal .Logger .Printf (ctx ,
462+ "hitless: no pool provided for connection %d, cannot remove due to handoff initialization failure: %v" ,
463+ conn .GetID (), err )
464+ }
458465 }
459466 return err
460467 }
@@ -480,17 +487,19 @@ func (ph *PoolHook) performConnectionHandoffWithPool(ctx context.Context, conn *
480487 // Remove the connection from the pool since it's in a bad state
481488 if pooler != nil {
482489 // Use pool.Pooler interface directly - no adapter needed
483- pooler .Remove (ctx , conn , err )
490+ go pooler .Remove (ctx , conn , err )
484491 if ph .config != nil && ph .config .LogLevel >= 1 { // Warning level
485492 internal .Logger .Printf (ctx ,
486493 "hitless: removed connection %d from pool due to handoff initialization failure: %v" ,
487494 conn .GetID (), err )
488495 }
489496 } else {
490- conn .Close ()
491- internal .Logger .Printf (ctx ,
492- "hitless: no pool provided for connection %d, cannot remove due to handoff initialization failure: %v" ,
493- conn .GetID (), err )
497+ go conn .Close ()
498+ if ph .config != nil && ph .config .LogLevel >= 1 { // Warning level
499+ internal .Logger .Printf (ctx ,
500+ "hitless: no pool provided for connection %d, cannot remove due to handoff initialization failure: %v" ,
501+ conn .GetID (), err )
502+ }
494503 }
495504
496505 // Keep the handoff state for retry
0 commit comments