session: fork Macaron mysql session middleware
This changes forks the mysql part of the Macaron session middleware. In the forked mysql file: - takes in a config setting for SetConnMaxLifetime (this solves wait_timeout problem if it is set to a shorter interval than wait_timeout) - removes the panic when an error is returned in the Exist function. - retries the exist query once - retries the GC query once
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
|
||||
ms "github.com/go-macaron/session"
|
||||
_ "github.com/go-macaron/session/memcache"
|
||||
_ "github.com/go-macaron/session/mysql"
|
||||
_ "github.com/go-macaron/session/postgres"
|
||||
_ "github.com/go-macaron/session/redis"
|
||||
"github.com/grafana/grafana/pkg/log"
|
||||
@@ -25,6 +24,7 @@ var sessionOptions *ms.Options
|
||||
var StartSessionGC func()
|
||||
var GetSessionCount func() int
|
||||
var sessionLogger = log.New("session")
|
||||
var sessionConnMaxLifetime int64
|
||||
|
||||
func init() {
|
||||
StartSessionGC = func() {
|
||||
@@ -37,9 +37,10 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
func Init(options *ms.Options) {
|
||||
func Init(options *ms.Options, connMaxLifetime int64) {
|
||||
var err error
|
||||
sessionOptions = prepareOptions(options)
|
||||
sessionConnMaxLifetime = connMaxLifetime
|
||||
sessionManager, err = ms.NewManager(options.Provider, *options)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
Reference in New Issue
Block a user