Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Merge pull request #767 from tomleb/never_down_again

Activate the never_go_down again switch (fix slowdown issue)
Cette révision appartient à :
tomleb 2017-05-26 16:20:44 -04:00 révisé par GitHub
révision 075b51e43c
4 fichiers modifiés avec 19 ajouts et 5 suppressions

Voir le fichier

@ -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)

Voir le fichier

@ -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"

Voir le fichier

@ -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

Voir le fichier

@ -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