Skip to content

Commit 026d474

Browse files
ekohlehelms
authored andcommitted
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.
1 parent e3bf011 commit 026d474

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

manifests/config.pp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
mode => '0640',
3636
}
3737

38+
if $foreman::use_foreman_service {
39+
$db_pool = max($foreman::db_pool, $foreman::foreman_service_puma_threads_max)
40+
} else {
41+
$db_pool = $foreman::db_pool
42+
}
43+
3844
file { '/etc/foreman/database.yml':
3945
owner => 'root',
4046
group => $foreman::group,

manifests/init.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@
8383
#
8484
# $db_root_cert:: Root cert used to verify SSL connection to postgres
8585
#
86-
# $db_pool:: Database 'production' size of connection pool
86+
# $db_pool:: Database 'production' size of connection pool. When running as a reverse proxy,
87+
# the value of `$foreman_service_puma_threads_max` is used if it's higher than `$db_pool`.
8788
#
8889
# $db_manage_rake:: if enabled, will run rake jobs, which depend on the database
8990
#

templates/database.yml.erb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,4 @@
2727
<% unless (password = scope.lookupvar("::foreman::db_password")) == 'UNSET' -%>
2828
password: "<%= password %>"
2929
<% end -%>
30-
<% unless (pool = scope.lookupvar("::foreman::db_pool")) == 'UNSET' -%>
31-
pool: <%= pool %>
32-
<% end -%>
30+
pool: <%= @db_pool %>

0 commit comments

Comments
 (0)