Skip to content

Commit c2f3938

Browse files
lunnylafriks
authored andcommitted
fix possbile mysql invalid connnection error (#7051)
1 parent 063fa99 commit c2f3938

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

models/models.go

Lines changed: 6 additions & 0 deletions
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/setting"
1920

@@ -278,6 +279,11 @@ func SetEngine() (err error) {
278279
// so use log file to instead print to stdout.
279280
x.SetLogger(NewXORMLogger(setting.LogSQL))
280281
x.ShowSQL(setting.LogSQL)
282+
if DbCfg.Type == "mysql" {
283+
x.SetMaxIdleConns(0)
284+
x.SetConnMaxLifetime(3 * time.Second)
285+
}
286+
281287
return nil
282288
}
283289

0 commit comments

Comments
 (0)