diff --git a/manifests/config.pp b/manifests/config.pp index fb9953d2..87fc9fd7 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -68,7 +68,9 @@ 'database' => $foreman::db_database, 'username' => $foreman::db_username, 'password' => $foreman::db_password, - 'db_pool' => max($foreman::db_pool, $foreman::foreman_service_puma_threads_max), + # Set the pool size to at least the amount of puma threads + 4 threads that are spawned automatically by the process. + # db_pool is optional, and undef means "use default" and the second part of the max statement will be set + 'db_pool' => pick($foreman::db_pool, $foreman::foreman_service_puma_threads_max + 4), } file { '/etc/foreman/database.yml': diff --git a/manifests/init.pp b/manifests/init.pp index 08d901d3..1839c02a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -84,8 +84,8 @@ # # $db_root_cert:: Root cert used to verify SSL connection to postgres # -# $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_pool:: Database 'production' size of connection pool. If the value is not set, it will be +# set by default to the amount of puma threads + 4 (for threads that are spawn by the system) # # $db_manage_rake:: if enabled, will run rake jobs, which depend on the database # @@ -226,7 +226,7 @@ String[1] $db_password = $foreman::params::db_password, Optional[String[1]] $db_sslmode = undef, Optional[String[1]] $db_root_cert = undef, - Integer[0] $db_pool = 5, + Optional[Integer[0]] $db_pool = undef, Boolean $db_manage_rake = true, Stdlib::Port $server_port = 80, Stdlib::Port $server_ssl_port = 443, diff --git a/spec/classes/foreman_spec.rb b/spec/classes/foreman_spec.rb index df552d35..35e4a2d6 100644 --- a/spec/classes/foreman_spec.rb +++ b/spec/classes/foreman_spec.rb @@ -199,7 +199,7 @@ db_username: 'foreman', db_password: 'secret', db_sslmode: 'prefer', - db_pool: 5, + db_pool: 9, db_manage_rake: true, server_port: 80, server_ssl_port: 443,