Skip to content

Commit e94b0a5

Browse files
committed
pool fix
1 parent 7801166 commit e94b0a5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

internal/pool/pool.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,13 @@ func (p *ConnPool) Put(ctx context.Context, cn *Conn) {
627627

628628
func (p *ConnPool) Remove(_ context.Context, cn *Conn, reason error) {
629629
p.removeConnWithLock(cn)
630-
p.freeTurn()
630+
631+
// Only free a turn if the connection was actually pooled
632+
// This prevents queue imbalance when removing connections that weren't obtained through Get()
633+
if cn.pooled {
634+
p.freeTurn()
635+
}
636+
631637
_ = p.closeConn(cn)
632638

633639
// Check if we need to create new idle connections to maintain MinIdleConns

0 commit comments

Comments
 (0)