go/src/database/sql
Chris Hines 6de40099c8 database/sql: avoid deadlock waiting for connections
Previously with db.maxOpen > 0, db.maxOpen+n failed connection attempts
started concurrently could result in a deadlock. DB.conn and
DB.openNewConnection did not trigger the DB.connectionOpener go routine
after a failed connection attempt. This omission could leave go routines
waiting for DB.connectionOpener forever.

In addition the logic to track the state of the pool was inconsistent.
db.numOpen was sometimes incremented optimistically and sometimes not.
This change harmonizes the logic and eliminates the db.pendingOpens
variable, making the logic easier to understand and maintain.

Fixes #10886

Change-Id: I983c4921a3dacfbd531c3d7f8d2da8a592e9922a
Reviewed-on: https://go-review.googlesource.com/14547
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-16 15:17:03 +00:00
..
driver
convert.go database/sql: fix conversions to and from user-defined types 2015-10-06 20:59:00 +00:00
convert_test.go database/sql: fix conversions to and from user-defined types 2015-10-06 20:59:00 +00:00
doc.txt
example_test.go
fakedb_test.go database/sql: avoid deadlock waiting for connections 2015-10-16 15:17:03 +00:00
sql.go database/sql: avoid deadlock waiting for connections 2015-10-16 15:17:03 +00:00
sql_test.go database/sql: avoid deadlock waiting for connections 2015-10-16 15:17:03 +00:00