Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-30 15:06:34 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-30 15:06:34 +0300
commit228d752ff09362002cc904d28edee7d63cc3cef2 (patch)
tree63e7ff466c0b0794f67c87c34e874f8682fb5de0 /config/initializers
parentb539ac1d619c0aafe5988ab8b125a8b43b14d87f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'config/initializers')
-rw-r--r--config/initializers/database_config.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/config/initializers/database_config.rb b/config/initializers/database_config.rb
new file mode 100644
index 00000000000..d8c2821066b
--- /dev/null
+++ b/config/initializers/database_config.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+# when running on puma, scale connection pool size with the number
+# of threads per worker process
+if defined?(::Puma)
+ db_config = Gitlab::Database.config ||
+ Rails.application.config.database_configuration[Rails.env]
+ puma_options = Puma.cli_config.options
+
+ # We use either the maximum number of threads per worker process, or
+ # the user specified value, whichever is larger.
+ desired_pool_size = [db_config['pool'].to_i, puma_options[:max_threads]].max
+
+ db_config['pool'] = desired_pool_size
+
+ # recreate the connection pool from the new config
+ ActiveRecord::Base.establish_connection(db_config)
+end