db fail 当前打开连接数

This commit is contained in:
李子铭 2025-03-20 17:24:36 +08:00
parent 37143f17fa
commit 71eb344f0c
1 changed files with 4 additions and 2 deletions

View File

@ -48,9 +48,11 @@ func db(data *conf.Data_Database) (*gorm.DB, func()) {
} }
// SetMaxIdleConns sets the maximum number of connections in the idle connection pool. // SetMaxIdleConns sets the maximum number of connections in the idle connection pool.
sqlDB.SetMaxIdleConns(int(data.MaxIdle)) //sqlDB.SetMaxIdleConns(int(data.MaxIdle))
sqlDB.SetMaxIdleConns(1000)
// SetMaxOpenConns sets the maximum number of openapi connections to the database. // SetMaxOpenConns sets the maximum number of openapi connections to the database.
sqlDB.SetMaxOpenConns(int(data.MaxOpen)) //sqlDB.SetMaxOpenConns(int(data.MaxOpen))
sqlDB.SetMaxOpenConns(3000)
// SetConnMaxLifetime sets the maximum amount of time a connection may be reused. // SetConnMaxLifetime sets the maximum amount of time a connection may be reused.
//sqlDB.SetConnMaxLifetime(1 * time.Hour) //sqlDB.SetConnMaxLifetime(1 * time.Hour)
sqlDB.SetConnMaxLifetime(7200 * time.Second) sqlDB.SetConnMaxLifetime(7200 * time.Second)