From 63cb160cb1e502ce28a809e8055f946f49a6e47c Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 29 May 2019 17:49:03 +0800 Subject: [PATCH] fix possbile mysql invalid connnection error (#7051) (#7071) --- models/models.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/models/models.go b/models/models.go index e7ecc67fc5..5f9f81f679 100644 --- a/models/models.go +++ b/models/models.go @@ -14,6 +14,7 @@ import ( "path" "path/filepath" "strings" + "time" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" @@ -277,6 +278,11 @@ func SetEngine() (err error) { // so use log file to instead print to stdout. x.SetLogger(log.XORMLogger) x.ShowSQL(setting.LogSQL) + if DbCfg.Type == "mysql" { + x.SetMaxIdleConns(0) + x.SetConnMaxLifetime(3 * time.Second) + } + return nil }