From 026d47434316b8ae318c5e42936edc12859ab475 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Mon, 7 Sep 2020 16:51:22 +0200 Subject: [PATCH] Fixes #30789 - Set DB pool size dynamically Every thread in the Puma worker can open a database connection. This means it needs to be taken into account to avoid exhasuting the pool. --- manifests/config.pp | 6 ++++++ manifests/init.pp | 3 ++- templates/database.yml.erb | 4 +--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 845773d16..01096128f 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -35,6 +35,12 @@ mode => '0640', } + if $foreman::use_foreman_service { + $db_pool = max($foreman::db_pool, $foreman::foreman_service_puma_threads_max) + } else { + $db_pool = $foreman::db_pool + } + file { '/etc/foreman/database.yml': owner => 'root', group => $foreman::group, diff --git a/manifests/init.pp b/manifests/init.pp index 2d7a9f568..9732a7119 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -83,7 +83,8 @@ # # $db_root_cert:: Root cert used to verify SSL connection to postgres # -# $db_pool:: Database 'production' size of connection pool +# $db_pool:: Database 'production' size of connection pool. When running as a reverse proxy, +# the value of `$foreman_service_puma_threads_max` is used if it's higher than `$db_pool`. # # $db_manage_rake:: if enabled, will run rake jobs, which depend on the database # diff --git a/templates/database.yml.erb b/templates/database.yml.erb index 1d6c27dc2..df313220e 100644 --- a/templates/database.yml.erb +++ b/templates/database.yml.erb @@ -27,6 +27,4 @@ <% unless (password = scope.lookupvar("::foreman::db_password")) == 'UNSET' -%> password: "<%= password %>" <% end -%> -<% unless (pool = scope.lookupvar("::foreman::db_pool")) == 'UNSET' -%> - pool: <%= pool %> -<% end -%> + pool: <%= @db_pool %>