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: mutex is not unlocked if context has an error #17518

Closed
BenLubar opened this issue Oct 19, 2016 · 1 comment
Closed

database/sql: mutex is not unlocked if context has an error #17518

BenLubar opened this issue Oct 19, 2016 · 1 comment
Milestone

Comments

@BenLubar
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version devel +ae14472 Wed Oct 19 07:11:16 2016 +0000 linux/amd64

What operating system and processor architecture are you using (go env)?

Ubuntu Xenial, Core 2 Duo E7500

GOARCH="amd64"
GOBIN="/home/ben/go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/ben/.golang-path:/home/ben/.golang-bootstrap/path:/home/ben/go"
GORACE=""
GOROOT="/home/ben/.golang"
GOTOOLDIR="/home/ben/.golang/pkg/tool/linux_amd64"
GCCGO="/usr/bin/gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build297317960=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

https://play.golang.org/p/ZBm2g9fwK-

What did you expect to see?

The program terminates successfully with no output.

What did you see instead?

The program hangs.

This is caused by a missing db.mu.Unlock() when the context has already expired

BeginContext is from #15123. Bug introduced in CL 29381.

@bradfitz bradfitz added this to the Go1.8 milestone Oct 19, 2016
AlekSi referenced this issue Oct 19, 2016
Add context methods to sql and sql/driver methods. If
the driver doesn't implement context methods the connection
pool will still handle timeouts when a query fails to return
in time or when a connection is not available from the pool
in time.

There will be a follow-up CL that will add support for
context values that specify transaction levels and modes
that a driver can use.

Fixes #15123

Change-Id: Ia99f3957aa3f177b23044dd99d4ec217491a30a7
Reviewed-on: https://go-review.googlesource.com/29381
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Oct 20, 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

4 participants