Skip to content

Commit c52ffce

Browse files
authored
fix connection leak when Pool.Query failed
pc.Close is missing when Pool.Query returned err isn't nil
1 parent eec03bd commit c52ffce

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pool.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,11 @@ func (p *Pool) Query(ctx context.Context, q Query) (*Cursor, error) {
164164

165165
if err == nil {
166166
cursor.releaseConn = releaseConn(c, pc)
167-
} else if c.isBad() {
168-
pc.MarkUnusable()
167+
} else {
168+
if c.isBad() {
169+
pc.MarkUnusable()
170+
}
171+
pc.Close()
169172
}
170173

171174
return cursor, err

0 commit comments

Comments
 (0)