summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-10-21 22:20:47 +0100
committerGitHub <noreply@github.com>2019-10-21 22:20:47 +0100
commitd8161ee3fd5d2991f70523b03421af4e6cf5b513 (patch)
treea8b50be951b69c6d2a10ebaf514ed2bede7f750b /modules
parent73f8069249f2b88bbe42a8fc3db06f0e91719200 (diff)
downloadgitea-d8161ee3fd5d2991f70523b03421af4e6cf5b513.tar.gz
gitea-d8161ee3fd5d2991f70523b03421af4e6cf5b513.zip
Expose db.SetMaxOpenConns and allow non MySQL dbs to set conn pool params (#8528)
* Expose db.SetMaxOpenConns and allow other dbs to set their connection params * Add note about port exhaustion Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>
Diffstat (limited to 'modules')
-rw-r--r--modules/setting/database.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/modules/setting/database.go b/modules/setting/database.go
index 2cac4824df..8c49ba3c5a 100644
--- a/modules/setting/database.go
+++ b/modules/setting/database.go
@@ -42,12 +42,11 @@ var (
DBConnectRetries int
DBConnectBackoff time.Duration
MaxIdleConns int
+ MaxOpenConns int
ConnMaxLifetime time.Duration
IterateBufferSize int
}{
- Timeout: 500,
- MaxIdleConns: 0,
- ConnMaxLifetime: 3 * time.Second,
+ Timeout: 500,
}
)
@@ -80,8 +79,13 @@ func InitDBConfig() {
Database.Charset = sec.Key("CHARSET").In("utf8", []string{"utf8", "utf8mb4"})
Database.Path = sec.Key("PATH").MustString(filepath.Join(AppDataPath, "gitea.db"))
Database.Timeout = sec.Key("SQLITE_TIMEOUT").MustInt(500)
- Database.MaxIdleConns = sec.Key("MAX_IDLE_CONNS").MustInt(0)
- Database.ConnMaxLifetime = sec.Key("CONN_MAX_LIFE_TIME").MustDuration(3 * time.Second)
+ Database.MaxIdleConns = sec.Key("MAX_IDLE_CONNS").MustInt(2)
+ if Database.UseMySQL {
+ Database.ConnMaxLifetime = sec.Key("CONN_MAX_LIFE_TIME").MustDuration(3 * time.Second)
+ } else {
+ Database.ConnMaxLifetime = sec.Key("CONN_MAX_LIFE_TIME").MustDuration(0)
+ }
+ Database.MaxOpenConns = sec.Key("MAX_OPEN_CONNS").MustInt(0)
Database.IterateBufferSize = sec.Key("ITERATE_BUFFER_SIZE").MustInt(50)
Database.LogSQL = sec.Key("LOG_SQL").MustBool(true)