db: cap the maximum number of simultaneous connections to the database

This commit is contained in:
nemunaire 2018-12-09 19:12:47 +01:00
parent 99ef5046db
commit 1b75547308

View File

@ -43,6 +43,8 @@ func DBInit(dsn string) (err error) {
return
}
db.SetMaxOpenConns(768)
_, err = db.Exec(`SET SESSION sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO';`)
for i := 0; err != nil && i < 15; i += 1 {
if _, err = db.Exec(`SET SESSION sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO';`); err != nil && i <= 5 {