-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #33974 - Change the pool size to threads + 4 #1161
Conversation
7bda3a9
to
0780c61
Compare
@pablomh Thanks for all the testing and experimenting. |
Hi @ShimShtein, according to our data, this change should be very welcome :) These are the results of our testing that justify this change:
Based on this testing, we agree that the minimum Foreman DB pool value where all these issues are addressed is 9. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ShimShtein This will reset the default value, to really fix this we need to also reset this in the installer through a migration. |
@ehelms Added a migration PR: theforeman/foreman-installer#937 |
manifests/init.pp
Outdated
@@ -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, | |||
Integer[0] $db_pool = 9, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make this:
Integer[0] $db_pool = 9, | |
Optional[Integer[0]] $db_pool = undef, |
That way, if we change it in the future it automatically gets recalculated. We would need to change the part in config.pp
to deal with it by using pick()
instead of max()
.
The DB migration could then simply be .delete('db_pool') if db_pool == 5
.
0780c61
to
6d1f3b7
Compare
@ekohl fixed both here and the installer |
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to document that the 4 is just needed for Katello.
@@ -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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On line 87 there's documentation for this parameter that's shown in the installer when using --full-help
. Perhaps you can update it to describe the behavior.
manifests/config.pp
Outdated
'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' => max(pick($foreman::db_pool, 0), $foreman::foreman_service_puma_threads_max + 4), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd keep this simple so you still provide the user with full control. For example if the + 4
part does give problems you still provide a way to override it.
'db_pool' => max(pick($foreman::db_pool, 0), $foreman::foreman_service_puma_threads_max + 4), | |
'db_pool' => pick($foreman::db_pool, $foreman::foreman_service_puma_threads_max + 4), |
6d1f3b7
to
5b43a41
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@evgeni Debian 12 is failing:
current directory:
/usr/share/foreman/vendor/ruby/3.1.0/gems/psych-5.1.2/ext/psych
/usr/bin/ruby3.1 -I /usr/lib/ruby/vendor_ruby -r
./siteconf20240512-4799-xgqy0g.rb extconf.rb
checking for yaml.h... no
yaml.h not found
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
But I thought theforeman/foreman-packaging@60435ac would address that.
manifests/init.pp
Outdated
# $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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took me a while to figure this out. Would this be clearer?
# set by default to the amount of puma threads + 4 (for threads that are spawn by the system) | |
# set by default to the amount of puma threads + 4 (for internal system threads) |
5b43a41
to
c20c0ca
Compare
According to an investigation described in https://community.theforeman.org/t/rails-connection-pool-size-optimizations/36675 foreman process spawns 4 additional threads that consume DB connection during the startup. Hence the amount of acctive DB connections should be the amount of puma threads + 4 additional threads.
c20c0ca
to
19f67cb
Compare
Should be a bit more clear now. |
According to an investigation described in https://community.theforeman.org/t/rails-connection-pool-size-optimizations/36675 foreman process spawns 4 additional threads that consume DB connection during the startup. Hence the amount of acctive DB connections should be the amount of puma threads + 4 additional threads.