-
Notifications
You must be signed in to change notification settings - Fork 18k
database/sql: SetConnMaxIdleTime without SetConnMaxLifetime has no effect #41114
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
Comments
/cc @kardianos |
This is very likely fixed with: |
@jeremyfaller Should we close this? |
I don't think the logic in that CL is correct nor do I think it fixes this, but I could be misunderstanding. After that CL, if maxIdle is less than 0, it is returned. I think the desire is for maxLifetime to be |
I think Seth's correct. https://go-review.googlesource.com/c/go/+/248817/ will unintentionally fix some of the cases of this issue. I think that CL also doesn't completely address what it intended to address. I'll see about putting something together to fix this completely. |
Change https://golang.org/cl/255966 mentions this issue: |
Connection's idleTime has below constraints.
this can be rewrote as below.
Connection's lifeTime also has below constraints.
Am I misunderstunding? |
I put together a CL that confirms the behavior through a test: Seth and I were both mistaken that there's a bug here. |
@jeremyfaller So this can be closed, if I understand correctly? |
What version of Go are you using (
go version
)?Custom version of
go branch [dev.link]
(1.16 as of about a week ago).Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Run the following:
If you run the following with:
MAXIDLE=1 MAXLIFE=0 SLEEP=5 go run .
You expect to see some idle connections closed. If you set MAXLIFE as well, the program works correctly, eg:
MAXIDLE=1 MAXLIFE=2 SLEEP=5 go run .
What did you expect to see?
SetConnMaxIdleTime
should have an effect without settingSetConnMaxLifetime
What did you see instead?
SetConnMaxIdleTime
should either:SetConnMaxLifetime
SetConnMaxLifetime
The error might be fixed by tweaking the callsite around
shortestIdleTimeLocked
The text was updated successfully, but these errors were encountered: