Skip to content

Commit 6deefcf

Browse files
committed
fix for empty endpoint
1 parent 4ec6958 commit 6deefcf

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

maintnotifications/push_notification_handler.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,28 @@ func (snh *NotificationHandler) handleMoving(ctx context.Context, handlerCtx pus
147147
if err := snh.markConnForHandoff(poolConn, newEndpoint, seqID, deadline); err != nil {
148148
// Log error but don't fail the goroutine - use background context since original may be cancelled
149149
internal.Logger.Printf(context.Background(), logs.FailedToMarkForHandoff(poolConn.GetID(), err))
150+
return
151+
}
152+
153+
// Queue the handoff immediately if the connection is idle in the pool.
154+
// If the connection is in use (StateInUse), it will be queued when returned to the pool via OnPut.
155+
// This handles the case where the connection is idle and might never be retrieved again.
156+
if poolConn.GetStateMachine().GetState() == pool.StateIdle {
157+
if snh.manager.poolHooksRef != nil && snh.manager.poolHooksRef.workerManager != nil {
158+
if err := snh.manager.poolHooksRef.workerManager.queueHandoff(poolConn); err != nil {
159+
internal.Logger.Printf(context.Background(), logs.FailedToQueueHandoff(poolConn.GetID(), err))
160+
} else {
161+
// Mark the connection as queued for handoff to prevent it from being retrieved
162+
// This transitions the connection to StateUnusable
163+
if err := poolConn.MarkQueuedForHandoff(); err != nil {
164+
internal.Logger.Printf(context.Background(), logs.FailedToMarkForHandoff(poolConn.GetID(), err))
165+
} else {
166+
internal.Logger.Printf(context.Background(), logs.MarkedForHandoff(poolConn.GetID()))
167+
}
168+
}
169+
}
150170
}
171+
// If connection is StateInUse, the handoff will be queued when it's returned to the pool
151172
})
152173
return nil
153174
}

0 commit comments

Comments
 (0)