From c2f3938a58aaff18b51224f05a0808d70e111d81 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 26 May 2019 21:28:33 +0800 Subject: [PATCH] fix possbile mysql invalid connnection error (#7051) --- models/models.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/models/models.go b/models/models.go index 85318af87..c1d4c100d 100644 --- a/models/models.go +++ b/models/models.go @@ -14,6 +14,7 @@ import ( "path" "path/filepath" "strings" + "time" "code.gitea.io/gitea/modules/setting" @@ -278,6 +279,11 @@ func SetEngine() (err error) { // so use log file to instead print to stdout. x.SetLogger(NewXORMLogger(setting.LogSQL)) x.ShowSQL(setting.LogSQL) + if DbCfg.Type == "mysql" { + x.SetMaxIdleConns(0) + x.SetConnMaxLifetime(3 * time.Second) + } + return nil }