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: update SetMaxIdleConns documentation to specify the default value #22138

Closed
pjebs opened this issue Oct 5, 2017 · 4 comments
Closed
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@pjebs
Copy link
Contributor

pjebs commented Oct 5, 2017

Can the team please update the documentation for SetMaxIdleConns to specify what the default value should be.

I fell into a trap in here: https://github.com/pjebs/go-skeleton/blob/master/config/database.go#L51
where the the struct I used will set SetMaxIdleConns to 0 (which is the zero-value of an int).

It turns out that intended default value is 2, but the documentation does not state that.

Also on a separate issue:
I don't think defaultMaxIdleConns const is actually used properly in the code. I suspect it is a bug.

@andizzle
Copy link

andizzle commented Oct 5, 2017

Can we have a test check here in sql_test to check the maxIdle value after Open() is called.

func TestMaxIdleConns(t *testing.T) {
	db := newTestDB(t, "people")
	defer closeDB(t, db)

        if db.maxIdle != defaultMaxIdleConns {
		t.Errorf("default max idle = %d; want %d", db.maxIdle, defaultMaxIdleConns)
        }

	tx, err := db.Begin()
...

@odeke-em odeke-em changed the title SetMaxIdleConns(n int) issue database/sql: update SetMaxIdleConns documentation to specify the default value Oct 5, 2017
@odeke-em
Copy link
Member

odeke-em commented Oct 5, 2017

/cc @kardianos

@kardianos kardianos self-assigned this Oct 31, 2017
@kardianos
Copy link
Contributor

I didn't get to it in time for go1.10. I'll think about this for go1.11.

@ianlancetaylor ianlancetaylor added this to the Go1.11 milestone Mar 29, 2018
@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Mar 29, 2018
@gopherbot
Copy link

Change https://golang.org/cl/108536 mentions this issue: database/sql: add additional Stats to DBStats

@golang golang locked and limited conversation to collaborators May 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants