Skip to content

Commit

Permalink
Fixes #30789 - Set DB pool size dynamically
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ekohl authored and ehelms committed Sep 25, 2020
1 parent e3bf011 commit 026d474
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 6 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
4 changes: 1 addition & 3 deletions templates/database.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>

0 comments on commit 026d474

Please sign in to comment.