Skip to content

proposal: database/sql: add MaxIdleConnections to DBStats  #52567

Open
@bonnefoa

Description

@bonnefoa

This is a proposal to add MaxIdleConnections to DBStats.

Currently, DBStats exports the following metrics:

type DBStats struct {
    MaxOpenConnections int // Maximum number of open connections to the database.

    // Pool Status
    OpenConnections int // The number of established connections both in use and idle.
    InUse           int // The number of connections currently in use.
    Idle            int // The number of idle connections.

    // Counters
    WaitCount         int64         // The total number of connections waited for.
    WaitDuration      time.Duration // The total time blocked waiting for a new connection.
    MaxIdleClosed     int64         // The total number of connections closed due to SetMaxIdleConns.
    MaxIdleTimeClosed int64         // The total number of connections closed due to SetConnMaxIdleTime.
    MaxLifetimeClosed int64         // The total number of connections closed due to SetConnMaxLifetime.
}

We had issues where our applications were configured with a MaxOpenConnections != MaxIdleConnections, leading to a lot of connection churning to the DB.
MaxOpenConnections is already available in the stats but MaxIdleConnections is missing, making it hard to track affected applications.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions