Skip to content

Commit 374eb2d

Browse files
committed
wip
1 parent 06ea120 commit 374eb2d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

internal/pool/pool.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,9 @@ func (p *ConnPool) Remove(_ context.Context, cn *Conn, reason error) {
614614
p.removeConnWithLock(cn)
615615
p.freeTurn()
616616
_ = p.closeConn(cn)
617+
618+
// Check if we need to create new idle connections to maintain MinIdleConns
619+
p.checkMinIdleConns()
617620
}
618621

619622
func (p *ConnPool) CloseConn(cn *Conn) error {
@@ -630,6 +633,11 @@ func (p *ConnPool) removeConnWithLock(cn *Conn) {
630633
func (p *ConnPool) removeConn(cn *Conn) {
631634
delete(p.conns, cn.GetID())
632635
atomic.AddUint32(&p.stats.StaleConns, 1)
636+
637+
// Decrement pool size counter when removing a connection
638+
if cn.pooled {
639+
p.poolSize.Add(-1)
640+
}
633641
}
634642

635643
func (p *ConnPool) closeConn(cn *Conn) error {

0 commit comments

Comments
 (0)