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
Labels
FeatureRequest FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@pjebs
Copy link
Contributor

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

Related #18080

@kardianos kardianos changed the title sql.DB diagostics information database/sql: DB diagostics information Apr 4, 2018
@kardianos kardianos added NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. FeatureRequest labels Apr 4, 2018
@bcmills
Copy link
Contributor

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 Issue is not actionable because of missing required information, which needs to be provided. and removed NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Apr 4, 2018
@bcmills bcmills added this to the Unplanned milestone Apr 4, 2018
@kardianos
Copy link
Contributor

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 added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels 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

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 commented Apr 17, 2018

LGTM

@pjebs
Copy link
Contributor Author

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

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

@pjebs
Copy link
Contributor Author

pjebs commented Apr 19, 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
FeatureRequest FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants