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: Goroutine freezes in database/sql. #23453

sundagy opened this issue Jan 15, 2018 · 4 comments

database/sql: Goroutine freezes in database/sql. #23453

sundagy opened this issue Jan 15, 2018 · 4 comments


Copy link

@sundagy sundagy commented Jan 15, 2018

In this weekends we came across a very unpleasant bug. The our server application is freezed after about 50min of works.
Using tool pprof/goroutine we did investigation and found that all 4 workers hang in the database/sql package:

ROUTINE ======================== database/sql.(*DB).conn in /usr/local/go/src/database/sql/sql.go
         0         20 (flat, cum) 0.0045% of Total
         .          .    965:           reqKey := db.nextRequestKeyLocked()
         .          .    966:           db.connRequests[reqKey] = req
         .          .    967: 
         .          .    968:
         .          .    969:           // Timeout the connection request with the context.
         .         20    970:           select {
         .          .    971:           case <-ctx.Done():
         .          .    972:                   // Remove the connection request and ensure no value has been sent
         .          .    973:                   // on it after removing.
         .          .    974:         
         .          .    975:                   delete(db.connRequests, reqKey)

What is most striking that until today's weekend the our server application for 2 past years worked stably. And hasn't meet such kind of bug.

Tool like netstat didn't see any network activity with mysql.

Mysql driver is here:

I know the sufficiency of information is poor and the bug is probably just not to repeat so easily.
But can someone tell what is going on in this part of that package. I think this will help me to find clue.

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

go version go1.9.2 linux/amd64

Does this issue reproduce with the latest release?

I don't know.

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

GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build053765279=/tmp/go-build -gno-record-gcc-switches"

What did you expect to see?

Processing query or return error.

What did you see instead?

After 50 minutes it is impossible to make queries to the database and the whole goroutine freeze.

Copy link

@davecheney davecheney commented Jan 15, 2018

pprof is the wrong tool for this job. You want to take a stack dump by sending SIGQUIT to your process.

I am going to close this issue as it doesn't appear to be a bug in Go. Unlike many projects on GitHub, the Go project does not use its bug tracker for general discussion or asking questions. We only use our bug tracker for tracking bugs and tracking proposals going through the Proposal Process.

Please see for good places to ask questions. If it turns out there is a bug in Go, they'll redirect you back here.

@davecheney davecheney closed this Jan 15, 2018
Copy link

@bradfitz bradfitz commented Jan 15, 2018

Copy link

@kardianos kardianos commented Jan 15, 2018

I'm slightly unsure of the exact issue you are experiencing but it sounds like a connection leak perhaps. Do make sure your transactions are being committed / rolled back.

I would also recommend you try out the go1.10 beta2 if you are able to.

@mikioh mikioh changed the title Goroutine freezes in database/sql. database/sql: Goroutine freezes in database/sql. Jan 16, 2018
Copy link

@sundagy sundagy commented Jan 21, 2018

Indeed, it was connection leak.

@golang golang locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.