这是一个将MaxIdleConnections添加到DBStats的提案。
目前,DBStats导出以下指标:
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.
}
我们遇到了这样的问题:我们的应用程序配置了MaxOpenConnections不等于MaxIdleConnections,导致大量连接在数据库之间切换。
虽然MaxOpenConnections已经在统计数据中可用,但缺少MaxIdleConnections,使得跟踪受影响的应用程序变得困难。
2条答案
按热度按时间svmlkihl1#
https://go.dev/cl/402334提到了这个问题:
database/sql: Add MaxIdleConnections to DBStats
mbjcgjjk2#
我同意这个提议。