Skip to content

Commit 9e6b9ba

Browse files
authored
Merge pull request #444 from xowenx/fix-connection-leak
fix connection leak when Pool.Query failed
2 parents eec03bd + c52ffce commit 9e6b9ba

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)