Merge pull request #767 from tomleb/never_down_again
Activate the never_go_down again switch (fix slowdown issue)
Cette révision appartient à :
révision
075b51e43c
4 fichiers modifiés avec 19 ajouts et 5 suppressions
18
db/gorm.go
18
db/gorm.go
|
@ -9,6 +9,10 @@ import (
|
|||
_ "github.com/jinzhu/gorm/dialects/sqlite" // Need for sqlite
|
||||
)
|
||||
|
||||
const (
|
||||
SqliteType = "sqlite3"
|
||||
)
|
||||
|
||||
// Logger interface
|
||||
type Logger interface {
|
||||
Print(v ...interface{})
|
||||
|
@ -32,15 +36,23 @@ func GormInit(conf *config.Config, logger Logger) (*gorm.DB, error) {
|
|||
return nil, openErr
|
||||
}
|
||||
|
||||
IsSqlite = conf.DBType == "sqlite"
|
||||
IsSqlite = conf.DBType == SqliteType
|
||||
|
||||
connectionErr := db.DB().Ping()
|
||||
if connectionErr != nil {
|
||||
log.CheckError(connectionErr)
|
||||
return nil, connectionErr
|
||||
}
|
||||
db.DB().SetMaxIdleConns(10)
|
||||
db.DB().SetMaxOpenConns(100)
|
||||
|
||||
// Negative MaxIdleConns means don't retain any idle connection
|
||||
maxIdleConns := -1
|
||||
if IsSqlite {
|
||||
// sqlite doesn't like having a negative maxIdleConns
|
||||
maxIdleConns = 10
|
||||
}
|
||||
|
||||
db.DB().SetMaxIdleConns(maxIdleConns)
|
||||
db.DB().SetMaxOpenConns(400)
|
||||
|
||||
if config.Environment == "DEVELOPMENT" {
|
||||
db.LogMode(true)
|
||||
|
|
|
@ -26,7 +26,7 @@ func (logger *errorLogger) Print(values ...interface{}) {
|
|||
|
||||
func TestGormInitSqlite(t *testing.T) {
|
||||
conf := config.New()
|
||||
conf.DBType = "sqlite3"
|
||||
conf.DBType = SqliteType
|
||||
conf.DBParams = ":memory:?cache=shared&mode=memory"
|
||||
conf.DBLogMode = "detailed"
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ max_pool = 4
|
|||
|
||||
# - Life time -
|
||||
|
||||
child_life_time = 300
|
||||
child_life_time = {{ child_life_time }}
|
||||
# Pool exits after being idle for this many seconds
|
||||
child_max_connections = 0
|
||||
# Pool exits after receiving that many connections
|
||||
|
|
|
@ -6,3 +6,5 @@ memqcache_total_size_byte: 10737418240
|
|||
memqcache_maxcache_byte: 131072000
|
||||
# Has to be bigger or equal to maxcache_byte
|
||||
memqcache_cache_block_size_byte: 131072000
|
||||
# 20 seconds idle max (application shouldn't even make idle connections)
|
||||
child_life_time: 20
|
||||
|
|
Référencer dans un nouveau ticket