Skip to content

Simplify DB connection pool size configuration (optional)

Jacob Vosmaer requested to merge jv-db-connections into master

What does this MR do?

This MR tries to simplify management of the Rails DB connection pool size. Because of the inherent risks, we err on the side of caution by using a new environment variable DB_USE_NEW_POOL_SIZE_LOGIC as an opt-in mechanism. Below we describe what happens when DB_USE_NEW_POOL_SIZE_LOGIC=1. If this variable is set to any other value, or unset, we keep the old behavior.

Prior to this MR, the application would calculate a number of connections it thought it needed, and then there were two configuration options to increase the number of connections: the pool: field in database.yml and the DB_POOL_HEADROOM environment variable.

In this MR, we still try to calculate how many connections we need, but there is only one way for administrators to increase the number of connections: DB_POOL_HEADROOM. This means that we will ignore whatever is in the pool: field in database.yml.

As before, we do do not allow administrators to decrease the number of connections. The only sane way to do that is to have fewer application threads. (Pedantically speaking, this is not correct, because DB_POOL_HEADROOM can be negative.)

There was also a distinction between multi-threaded and single-threaded processes. When DB_USE_NEW_POOL_SIZE_LOGIC=1 we always perform the same headroom calculation (what used to be the multi-threaded case).

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Jacob Vosmaer

Merge request reports

Loading