models: disable idle connection and set connection max life time (#5532)

This commit is contained in:
Unknwon 2019-02-06 18:46:15 -05:00
parent d862c43be0
commit 0a176df6fb
3 changed files with 8 additions and 2 deletions

View File

@ -16,7 +16,7 @@ import (
"github.com/gogs/gogs/pkg/setting"
)
const APP_VER = "0.11.86.0130"
const APP_VER = "0.11.87.0206"
func init() {
setting.AppVer = APP_VER

View File

@ -13,6 +13,7 @@ import (
"os"
"path"
"strings"
"time"
"github.com/Unknwon/com"
_ "github.com/denisenkom/go-mssqldb"
@ -200,6 +201,11 @@ func SetEngine() (err error) {
return fmt.Errorf("Fail to create 'xorm.log': %v", err)
}
// To prevent mystery "MySQL: invalid connection" error,
// see https://github.com/gogs/gogs/issues/5532.
x.SetMaxIdleConns(0)
x.SetConnMaxLifetime(time.Second)
if setting.ProdMode {
x.SetLogger(xorm.NewSimpleLogger3(logger, xorm.DEFAULT_LOG_PREFIX, xorm.DEFAULT_LOG_FLAG, core.LOG_WARNING))
} else {

View File

@ -1 +1 @@
0.11.86.0130
0.11.87.0206