db: cap the maximum number of simultaneous connections to the database
authorPierre-Olivier Mercier <nemunaire@nemunai.re>
Sun, 9 Dec 2018 18:12:47 +0000 (19:12 +0100)
committerPierre-Olivier Mercier <nemunaire@nemunai.re>
Sun, 9 Dec 2018 23:31:29 +0000 (00:31 +0100)
libfic/db.go

index f9b305f..d61f153 100644 (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 {