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: add DB connection diagnostics #24683

Closed
pjebs opened this issue Apr 4, 2018 · 9 comments
Closed

database/sql: add DB connection diagnostics #24683

pjebs opened this issue Apr 4, 2018 · 9 comments

Comments

@pjebs
Copy link
Contributor

@pjebs pjebs commented Apr 4, 2018

Currently the *DB object (which represents a pool of connections) allows these settings:

  • SetConnMaxLifetime(d time.Duration)
  • SetMaxIdleConns(n int)
  • SetMaxOpenConns(n int)

The aim of my proposal is to assist Go developers to tune these values.

Perhaps the DBStats object which currently only indicates how many open connections exist can indicate how many open connections are on average blocked and how long they are blocked for, for our typical application.

That will allow us to perhaps set a higher SetMaxOpenConns value.

@kardianos
Copy link
Contributor

@kardianos kardianos commented Apr 4, 2018

Related #18080

@kardianos kardianos changed the title sql.DB diagostics information database/sql: DB diagostics information Apr 4, 2018
@bcmills
Copy link
Member

@bcmills bcmills commented Apr 4, 2018

This issue in its current form does not have enough detail to be a proposal.

If you want to describe a general area for improvement, please add an experience report instead.

Otherwise, please describe the specific changes you would like to see, including the motivation or background, syntax or API signatures, and concrete examples (ideally drawn from experience reports).

@bcmills bcmills added WaitingForInfo and removed NeedsDecision labels Apr 4, 2018
@bcmills bcmills added this to the Unplanned milestone Apr 4, 2018
@kardianos
Copy link
Contributor

@kardianos kardianos commented Apr 4, 2018

Sorry, I mislabeled it. I attempted to choose labels that conveyed "yes, I agree this would be good, we can track this separately, but I'm not sure how to best achieve this yet."

@bcmills bcmills modified the milestones: Unplanned, Proposal Apr 4, 2018
@bcmills bcmills changed the title database/sql: DB diagostics information proposal: database/sql: DB connection diagnostics Apr 4, 2018
@bcmills bcmills changed the title proposal: database/sql: DB connection diagnostics database/sql: add DB connection diagnostics Apr 4, 2018
@bcmills bcmills modified the milestones: Proposal, Unplanned Apr 4, 2018
@kardianos
Copy link
Contributor

@kardianos kardianos commented Apr 16, 2018

I would be interested to specifically add the following stats:

// Pool Configuration.
Capacity int              // The capacity of the connection pool.
IdleTimeout time.Duration // Zero if no idle timeout should apply to the pool.

// Pool Status
Available int // The number of free connections within the pool.
OpenConnections int    // The number of connections both in use and in the pool.
InUse int     // The number of connections currently in use.

// Counters
WaitCount int64        // The total number of connections waited for.
WaitTime time.Duration // The total time blocked waiting for a new connection.
IdleClosed int64       // The total count of connections closed due to idle.

@pjebs Would these statistics work for you?

@pjebs
Copy link
Contributor Author

@pjebs pjebs commented Apr 17, 2018

LGTM

@pjebs
Copy link
Contributor Author

@pjebs pjebs commented Apr 17, 2018

maybe for WaitCount and WaitTime, (avg) per time might be better but not per time is still workable

@kardianos
Copy link
Contributor

@kardianos kardianos commented Apr 17, 2018

Couters play nice with systems like Prometheus and influx. We can derive averages from them at any interval.

@gopherbot
Copy link

@gopherbot gopherbot commented Apr 20, 2018

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

@gopherbot gopherbot closed this in d89ea41 May 11, 2018
@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.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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