Set PgBouncer pool_mode to session since pg_advisory_lock cannot be supported by transaction mode
Set a predefined number for the maximum connections to the database server from each PgBouncer unit to be 50. Those are the maximum connections that MAAS up to 3.4 requires per region controller (40), plus a buffer of 10. PgBouncer units are subordinate units of maas-region units, so it has to be a 1-1 mapping. The extra 10, if not used they will be closed by PgBouncer.
Provide a mechanism to configure experimental_max_connections to PostgreSQL charm with three options:
default: It does not set experimental_max_connections at all. It will use the system defaults of PostgreSQL
dynamic: It configures experimental_max_connections based on the number of maas-region units. If chosen, it will use the maximum of 100 (default max connections) and 50 * number_of_region_units + 10 (required by PgBouncer). This option also includes a restart of the PostgreSQL server units, so it is up to the practitioner to use it.
exact number of connections (100<=n<=500): It statically configures the experimental_max_connections of the PostgreSQL server. If specified during bootstrap (e.g., the MAAS cluster topology is predefined and total number of regions is known), it will be set from the beginning.
A ReapplyPostgreSQLTerraformPlanStep that will re-configure the experimental_max_connections when new region nodes are joining/leaving the cluster and max_connections mechanism is set to dynamic
A small refactor on the functions that fetch all the Steps of a given role
The PR includes the following changes:
pool_mode
tosession
sincepg_advisory_lock
cannot be supported bytransaction
modemaas-region
units, so it has to be a 1-1 mapping. The extra 10, if not used they will be closed by PgBouncer.experimental_max_connections
to PostgreSQL charm with three options:default
: It does not setexperimental_max_connections
at all. It will use the system defaults of PostgreSQLdynamic
: It configuresexperimental_max_connections
based on the number of maas-region units. If chosen, it will use the maximum of 100 (default max connections) and 50 *number_of_region_units
+ 10 (required by PgBouncer). This option also includes a restart of the PostgreSQL server units, so it is up to the practitioner to use it.100<=n<=500
): It statically configures theexperimental_max_connections
of the PostgreSQL server. If specified during bootstrap (e.g., the MAAS cluster topology is predefined and total number of regions is known), it will be set from the beginning.ReapplyPostgreSQLTerraformPlanStep
that will re-configure theexperimental_max_connections
when newregion
nodes are joining/leaving the cluster and max_connections mechanism is set todynamic
Fixes: #11