Skip to content

Commit

Permalink
fix: add connection timeout for db conn pool (#1032)
Browse files Browse the repository at this point in the history
Co-authored-by: HAOYUatHZ <[email protected]>
  • Loading branch information
cch123 and 0xmountaintop authored Dec 11, 2023
1 parent bc5ec89 commit 2e627f7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bridge-history-api/utils/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ func InitDB(config *config.DBConfig) (*gorm.DB, error) {
return nil, pingErr
}

sqlDB.SetConnMaxLifetime(time.Minute * 10)
sqlDB.SetConnMaxIdleTime(time.Minute * 5)
sqlDB.SetMaxOpenConns(config.MaxOpenNum)
sqlDB.SetMaxIdleConns(config.MaxIdleNum)

Expand Down
3 changes: 3 additions & 0 deletions common/database/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ func InitDB(config *Config) (*gorm.DB, error) {
return nil, pingErr
}

sqlDB.SetConnMaxLifetime(time.Minute * 10)
sqlDB.SetConnMaxIdleTime(time.Minute * 5)

sqlDB.SetMaxOpenConns(config.MaxOpenNum)
sqlDB.SetMaxIdleConns(config.MaxIdleNum)

Expand Down
2 changes: 1 addition & 1 deletion common/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"runtime/debug"
)

var tag = "v4.3.42"
var tag = "v4.3.43"

var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {
Expand Down

0 comments on commit 2e627f7

Please sign in to comment.