]> Cypherpunks repositories - gostls13.git/commit
database/sql: Retry with a fresh connection after maxBadConnRetries
authorMarko Tiikkaja <marko@joh.to>
Fri, 27 Mar 2015 18:45:12 +0000 (19:45 +0100)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 8 Apr 2015 16:18:36 +0000 (16:18 +0000)
commitc468f94672af25bc34975ba96309e20e972fa340
tree3647ad6bb35eb2969a7f4c0231b9c17e4434f058
parentd5ef69814204f1bf8bee75bc89efcbcb33a64606
database/sql: Retry with a fresh connection after maxBadConnRetries

Previously if the connection pool was larger than maxBadConnRetries
and there were a lot of bad connections in the pool (for example if
the database server was restarted), a query might have failed with an
ErrBadConn unnecessarily.  Instead of trying to guess how many times
to retry, try maxBadConnRetries times and then force a fresh
connection to be used for the last attempt.  At the same time, lower
maxBadConnRetries to a smaller value now that it's not that important
to retry so many times from the free connection list.

Fixes #8834

Change-Id: I6542f151a766a658980fb396fa4880ecf5874e3d
Reviewed-on: https://go-review.googlesource.com/2034
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/database/sql/fakedb_test.go
src/database/sql/sql.go
src/database/sql/sql_test.go