Skip to content

Commit

Permalink
Follow MySQL Important settings: https://github.com/go-sql-driver/mys…
Browse files Browse the repository at this point in the history
  • Loading branch information
ikeikeikeike committed Feb 6, 2024
1 parent e27c800 commit 7356e77
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions util/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ func SelectDBConn(dialect, dsn string) (*sql.DB, error) {
//
// https://github.blog/2020-05-20-three-bugs-in-the-go-mysql-driver/
// Oh Gawd
// https://github.com/go-sql-driver/mysql/issues/1302#issuecomment-1019842712
db.SetConnMaxLifetime(time.Minute * 5) // https://github.com/go-sql-driver/mysql/issues/1120#issuecomment-636795680
db.SetMaxIdleConns(4)
db.SetMaxOpenConns(8)
// - https://github.com/go-sql-driver/mysql/issues/1302#issuecomment-1019842712
// - https://github.com/go-sql-driver/mysql/issues/1120#issuecomment-636795680
//
//
// https://github.com/go-sql-driver/mysql?tab=readme-ov-file#important-settings
db.SetConnMaxLifetime(time.Minute * 3)
db.SetMaxIdleConns(5)
db.SetMaxOpenConns(5)

// make sure connection available
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
Expand Down

0 comments on commit 7356e77

Please sign in to comment.