Skip to content

Commit 63cb160

Browse files
lunnyzeripath
authored andcommitted
fix possbile mysql invalid connnection error (#7051) (#7071)
1 parent 8d5c3d3 commit 63cb160

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

models/models.go

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"path"
1515
"path/filepath"
1616
"strings"
17+
"time"
1718

1819
"code.gitea.io/gitea/modules/log"
1920
"code.gitea.io/gitea/modules/setting"
@@ -277,6 +278,11 @@ func SetEngine() (err error) {
277278
// so use log file to instead print to stdout.
278279
x.SetLogger(log.XORMLogger)
279280
x.ShowSQL(setting.LogSQL)
281+
if DbCfg.Type == "mysql" {
282+
x.SetMaxIdleConns(0)
283+
x.SetConnMaxLifetime(3 * time.Second)
284+
}
285+
280286
return nil
281287
}
282288

0 commit comments

Comments
 (0)