Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

database/sql: hang when driver panics #13677

Closed
rsc opened this issue Dec 18, 2015 · 3 comments
Closed

database/sql: hang when driver panics #13677

rsc opened this issue Dec 18, 2015 · 3 comments
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Dec 18, 2015

Debugging a hang in a program using Go 1.6.
Looks like the sqlite3 driver has buggy cgo usage, which triggers a panic during a call to a driver method with one of the database/sql locks held. The panic invokes some deferred functions higher up the stack without unlocking the lock. Those functions try to get the lock for themselves and deadlock. Looks like maybe database/sql needs to use defer to guard its various calls into the driver.

I started this for the driver.Stmt methods, but there are a lot.

/cc @bradfitz

@rsc rsc added this to the Go1.6 milestone Dec 18, 2015
@gopherbot
Copy link

CL https://golang.org/cl/18046 mentions this issue.

rsc added a commit that referenced this issue Jan 8, 2016
For #13677, but there is more to do.

Change-Id: Id1af999dc972d07cdfc771e5855a1a7dca47ca96
Reviewed-on: https://go-review.googlesource.com/18046
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@rsc rsc modified the milestones: Go1.6Maybe, Go1.6 Jan 14, 2016
@rsc
Copy link
Contributor Author

rsc commented Jan 14, 2016

I fixed the ones that I've seen buggy cgo-based database drivers hit. I think we'll leave the rest for Go 1.7 since these are in some cases actual logic changes to database/sql.

@rsc rsc modified the milestones: Go1.7, Go1.6Maybe Jan 14, 2016
@rsc rsc modified the milestones: Go1.8, Go1.7 May 18, 2016
jbowens added a commit to jbowens/go that referenced this issue Aug 29, 2016
The existing implementation may deadlock if the driver.Conn
implementation panics, so use defers to ensure mutexes are unlocked
even if the driver panics.

For golang#13677, but there is more to do.
@gopherbot
Copy link

CL https://golang.org/cl/27995 mentions this issue.

@golang golang locked and limited conversation to collaborators Aug 29, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants