Merge pull request 'Limit database max connections by default' (#3383) from fnetx/Limit database max connections by default into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3383
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
Earl Warren 2024-04-26 08:31:15 +00:00
commit 801554f708
2 changed files with 3 additions and 3 deletions

View File

@ -407,8 +407,8 @@ USER = root
;; Database connection max life time, default is 0 or 3s mysql (See #6804 & #7071 for reasoning) ;; Database connection max life time, default is 0 or 3s mysql (See #6804 & #7071 for reasoning)
;CONN_MAX_LIFETIME = 3s ;CONN_MAX_LIFETIME = 3s
;; ;;
;; Database maximum number of open connections, default is 0 meaning no maximum ;; Database maximum number of open connections, default is 100 which is the lowest default from Postgres (MariaDB + MySQL default to 151). Ensure you only increase the value if you configured your database server accordingly.
;MAX_OPEN_CONNS = 0 ;MAX_OPEN_CONNS = 100
;; ;;
;; Whether execute database models migrations automatically ;; Whether execute database models migrations automatically
;AUTO_MIGRATION = true ;AUTO_MIGRATION = true

View File

@ -83,7 +83,7 @@ func loadDBSetting(rootCfg ConfigProvider) {
Database.ConnMaxLifetime = sec.Key("CONN_MAX_LIFETIME").MustDuration(0) Database.ConnMaxLifetime = sec.Key("CONN_MAX_LIFETIME").MustDuration(0)
} }
Database.ConnMaxIdleTime = sec.Key("CONN_MAX_IDLETIME").MustDuration(0) Database.ConnMaxIdleTime = sec.Key("CONN_MAX_IDLETIME").MustDuration(0)
Database.MaxOpenConns = sec.Key("MAX_OPEN_CONNS").MustInt(0) Database.MaxOpenConns = sec.Key("MAX_OPEN_CONNS").MustInt(100)
Database.IterateBufferSize = sec.Key("ITERATE_BUFFER_SIZE").MustInt(50) Database.IterateBufferSize = sec.Key("ITERATE_BUFFER_SIZE").MustInt(50)
Database.LogSQL = sec.Key("LOG_SQL").MustBool(false) Database.LogSQL = sec.Key("LOG_SQL").MustBool(false)