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: support connection wait timeout when out of free connections #16174

Closed
NeoCN opened this issue Jun 24, 2016 · 5 comments
Closed

database/sql: support connection wait timeout when out of free connections #16174

NeoCN opened this issue Jun 24, 2016 · 5 comments
Milestone

Comments

@NeoCN
Copy link

@NeoCN NeoCN commented Jun 24, 2016

  1. What version of Go are you using (go version)?
    go version go1.6.2 darwin/amd64
  2. What operating system and processor architecture are you using (go env)?
    GOHOSTARCH="amd64"
    GOHOSTOS="darwin"
  3. What did you do?
    set the db.maxOpen to limit connections count.
    and try to do db query when connection pool is out of free connections
  4. What did you expect to see?
    expect database/sql support connection wait timeout setting, the connection wait timeout specifies how long an db request waits to obtain a connection if there are no longer any free connections in the pool.
    with this setting, we can make the db request fail fast when out of free connections
  5. What did you see instead?
    according the related code block https://github.com/golang/go/blob/master/src/database/sql/sql.go#L800-L817, the db request will wait, until get an connection to return, when returned, the application may have been waiting for 10s, or longer 10min.
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Jun 24, 2016
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jun 24, 2016

@h12w
Copy link

@h12w h12w commented Aug 2, 2016

It seems to be the same as #13327

@redfoxli
Copy link

@redfoxli redfoxli commented Aug 6, 2016

Support connection wait timeout is a good idea.
In our online environment, that's what I did.

Another way, it can return when out of free connections, like the treatment method of redis pool.
https://github.com/garyburd/redigo/blob/master/redis/pool.go#L124

@kardianos
Copy link
Contributor

@kardianos kardianos commented Oct 8, 2016

This should be closed now that #15123 is completed.

@bradfitz bradfitz closed this Oct 9, 2016
@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Oct 9, 2016

Done.

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

Successfully merging a pull request may close this issue.

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