From 4373801f932524d6da8e1600446b86c254030fe8 Mon Sep 17 00:00:00 2001 From: lawlielt Date: Tue, 5 Mar 2024 17:15:29 +0800 Subject: [PATCH] fix: fix the maxActiveConns sematic --- internal/pool/pool.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/pool/pool.go b/internal/pool/pool.go index 2125f3e1..1cfcf9da 100644 --- a/internal/pool/pool.go +++ b/internal/pool/pool.go @@ -169,7 +169,7 @@ func (p *ConnPool) newConn(ctx context.Context, pooled bool) (*Conn, error) { } p.connsMu.Lock() - if p.cfg.MaxActiveConns > 0 && p.poolSize >= p.cfg.MaxActiveConns { + if p.cfg.MaxActiveConns > 0 && len(p.conns) >= p.cfg.MaxActiveConns { p.connsMu.Unlock() return nil, ErrPoolExhausted } @@ -183,7 +183,7 @@ func (p *ConnPool) newConn(ctx context.Context, pooled bool) (*Conn, error) { p.connsMu.Lock() defer p.connsMu.Unlock() - if p.cfg.MaxActiveConns > 0 && p.poolSize >= p.cfg.MaxActiveConns { + if p.cfg.MaxActiveConns > 0 && len(p.conns) >= p.cfg.MaxActiveConns { _ = cn.Close() return nil, ErrPoolExhausted }