[all] reduce mysql-pooling to sensible defaults

Reduce the max_pool_size parameter from default 5 to 2, to reduce the
max number of connections each process needs.
Reduce connection_recycle_time from 200 to 20, to reduce life duration
of a connection, allowing faster recovery in case of failure of a
mysql-router.
Configure horizon-k8s to persist connections for 20 seconds, and enable
connection healthchecks to make sure the connection is usable.

Change-Id: Id88d5a8643b8dd2db618e18c8ad556f3e92282ba
This commit is contained in:
Guillaume Boutry 2024-06-17 11:31:47 +02:00
parent da9f54d56f
commit 90a585370c
No known key found for this signature in database
GPG Key ID: E95E3326872E55DE
11 changed files with 62 additions and 44 deletions

View File

@ -6,8 +6,7 @@ state_path = /var/lib/barbican
host_href = "" host_href = ""
transport_url = {{ amqp.transport_url }} transport_url = {{ amqp.transport_url }}
sql_connection = {{ database.connection }} {% include "parts/section-database" %}
db_auto_create = false
{% include "parts/section-identity" %} {% include "parts/section-identity" %}
# XXX Region should come from the id relation here # XXX Region should come from the id relation here

View File

@ -25,11 +25,7 @@ cinder_internal_tenant_project_id = {{ identity_credentials.project_id }}
cinder_internal_tenant_user_id = {{ identity_credentials.username }} cinder_internal_tenant_user_id = {{ identity_credentials.username }}
{% endif -%} {% endif -%}
[database] {% include "parts/section-database" %}
{% if database.connection -%}
connection = {{ database.connection }}
{% endif -%}
connection_recycle_time = 200
{% include "parts/section-oslo-notifications" %} {% include "parts/section-oslo-notifications" %}

View File

@ -21,6 +21,6 @@ enabled = True
[storage:sqlalchemy] [storage:sqlalchemy]
{% include "parts/database-connection" %} {% include "parts/database-connection" %}
db_auto_create = false {% include "parts/database-connection-settings" %}
{% include "parts/section-oslo-messaging-rabbit" %} {% include "parts/section-oslo-messaging-rabbit" %}

View File

@ -161,6 +161,8 @@ DATABASES = {
'PASSWORD': '{{ database.database_password }}', 'PASSWORD': '{{ database.database_password }}',
'HOST': '{{ database.database_host.split(':')[0] }}', 'HOST': '{{ database.database_host.split(':')[0] }}',
'PORT': '{{ database.database_host.split(':')[1] }}', 'PORT': '{{ database.database_host.split(':')[1] }}',
'CONN_MAX_AGE': 20,
'CONN_HEALTH_CHECKS': True,
'default-character-set': 'utf8' 'default-character-set': 'utf8'
} }
} }

View File

@ -11,7 +11,7 @@ connection = {{ api_database.connection }}
{% else -%} {% else -%}
connection = sqlite:////var/lib/nova/nova_api.sqlite connection = sqlite:////var/lib/nova/nova_api.sqlite
{% endif -%} {% endif -%}
connection_recycle_time = 200 {% include "parts/database-connection-settings" %}
{% include "parts/section-database" %} {% include "parts/section-database" %}

View File

@ -6,6 +6,7 @@ auth_strategy = keystone
[placement_database] [placement_database]
{% include "parts/database-connection" %} {% include "parts/database-connection" %}
{% include "parts/database-connection-settings" %}
{% include "parts/section-identity" %} {% include "parts/section-identity" %}

View File

@ -115,6 +115,8 @@ class TestPlacementOperatorCharm(test_utils.CharmTestCase):
[placement_database] [placement_database]
connection = mysql+pymysql://foo:hardpassword@10.0.0.10/placement_api connection = mysql+pymysql://foo:hardpassword@10.0.0.10/placement_api
connection_recycle_time = 20
max_pool_size = 2
[keystone_authtoken] [keystone_authtoken]
auth_url = http://keystone.internal:5000 auth_url = http://keystone.internal:5000

View File

@ -190,6 +190,7 @@ EXTERNAL_TEMPEST_LIBS=(
CONFIG_TEMPLATES_AODH=( CONFIG_TEMPLATES_AODH=(
"parts/section-database" "parts/section-database"
"parts/database-connection" "parts/database-connection"
"parts/database-connection-settings"
"parts/section-identity" "parts/section-identity"
"parts/identity-data" "parts/identity-data"
"parts/section-oslo-messaging-rabbit" "parts/section-oslo-messaging-rabbit"
@ -198,10 +199,13 @@ CONFIG_TEMPLATES_AODH=(
) )
CONFIG_TEMPLATES_BARBICAN=( CONFIG_TEMPLATES_BARBICAN=(
"parts/section-identity" "parts/section-database"
"parts/database-connection"
"parts/database-connection-settings"
"parts/section-identity"
"parts/identity-data" "parts/identity-data"
"parts/section-oslo-messaging-rabbit" "parts/section-oslo-messaging-rabbit"
"parts/section-service-user" "parts/section-service-user"
"ca-bundle.pem.j2" "ca-bundle.pem.j2"
) )
@ -213,54 +217,61 @@ CONFIG_TEMPLATES_CEILOMETER=(
) )
CONFIG_TEMPLATES_CINDER=( CONFIG_TEMPLATES_CINDER=(
"parts/section-database" "parts/section-database"
"parts/database-connection" "parts/database-connection"
"parts/section-identity" "parts/database-connection-settings"
"parts/section-identity"
"parts/identity-data" "parts/identity-data"
"parts/section-oslo-messaging-rabbit" "parts/section-oslo-messaging-rabbit"
"parts/section-service-user" "parts/section-service-user"
"ca-bundle.pem.j2" "ca-bundle.pem.j2"
) )
CONFIG_TEMPLATES_CINDER_CEPH=( CONFIG_TEMPLATES_CINDER_CEPH=(
"parts/section-database"
"parts/database-connection"
"parts/database-connection-settings"
"parts/section-oslo-messaging-rabbit" "parts/section-oslo-messaging-rabbit"
"parts/section-oslo-notifications" "parts/section-oslo-notifications"
) )
CONFIG_TEMPLATES_DESIGNATE=( CONFIG_TEMPLATES_DESIGNATE=(
"parts/database-connection" "parts/database-connection"
"parts/database-connection-settings"
"parts/section-identity" "parts/section-identity"
"parts/identity-data" "parts/identity-data"
"parts/section-oslo-messaging-rabbit" "parts/section-oslo-messaging-rabbit"
"parts/section-service-user" "parts/section-service-user"
"ca-bundle.pem.j2" "ca-bundle.pem.j2"
) )
CONFIG_TEMPLATES_GLANCE=( CONFIG_TEMPLATES_GLANCE=(
"parts/section-database" "parts/section-database"
"parts/database-connection" "parts/database-connection"
"parts/database-connection-settings"
"parts/section-identity" "parts/section-identity"
"parts/identity-data" "parts/identity-data"
"parts/section-oslo-messaging-rabbit" "parts/section-oslo-messaging-rabbit"
"parts/section-oslo-notifications" "parts/section-oslo-notifications"
"parts/section-service-user" "parts/section-service-user"
"ca-bundle.pem.j2" "ca-bundle.pem.j2"
) )
CONFIG_TEMPLATES_GNOCCHI=( CONFIG_TEMPLATES_GNOCCHI=(
"parts/database-connection" "parts/database-connection"
"parts/section-identity" "parts/section-identity"
"parts/identity-data" "parts/identity-data"
"ca-bundle.pem.j2" "ca-bundle.pem.j2"
) )
CONFIG_TEMPLATES_HEAT=( CONFIG_TEMPLATES_HEAT=(
"parts/section-database" "parts/section-database"
"parts/database-connection" "parts/database-connection"
"parts/section-identity" "parts/database-connection-settings"
"parts/identity-data" "parts/section-identity"
"parts/identity-data"
"parts/section-trustee" "parts/section-trustee"
"parts/section-oslo-messaging-rabbit" "parts/section-oslo-messaging-rabbit"
"ca-bundle.pem.j2" "ca-bundle.pem.j2"
) )
@ -271,6 +282,7 @@ CONFIG_TEMPLATES_HORIZON=(
CONFIG_TEMPLATES_KEYSTONE=( CONFIG_TEMPLATES_KEYSTONE=(
"parts/section-database" "parts/section-database"
"parts/database-connection" "parts/database-connection"
"parts/database-connection-settings"
"parts/section-federation" "parts/section-federation"
"parts/section-middleware" "parts/section-middleware"
"parts/section-oslo-cache" "parts/section-oslo-cache"
@ -283,8 +295,9 @@ CONFIG_TEMPLATES_KEYSTONE=(
CONFIG_TEMPLATES_MAGNUM=( CONFIG_TEMPLATES_MAGNUM=(
"parts/section-database" "parts/section-database"
"parts/database-connection" "parts/database-connection"
"parts/database-connection-settings"
"parts/section-identity" "parts/section-identity"
"parts/identity-data" "parts/identity-data"
"parts/section-oslo-messaging-rabbit" "parts/section-oslo-messaging-rabbit"
"parts/section-service-user" "parts/section-service-user"
"parts/section-trust" "parts/section-trust"
@ -292,30 +305,33 @@ CONFIG_TEMPLATES_MAGNUM=(
) )
CONFIG_TEMPLATES_NEUTRON=( CONFIG_TEMPLATES_NEUTRON=(
"parts/section-database" "parts/section-database"
"parts/database-connection" "parts/database-connection"
"parts/section-identity" "parts/database-connection-settings"
"parts/identity-data" "parts/section-identity"
"parts/section-oslo-messaging-rabbit" "parts/identity-data"
"parts/section-service-user" "parts/section-oslo-messaging-rabbit"
"parts/section-service-user"
"ca-bundle.pem.j2" "ca-bundle.pem.j2"
) )
CONFIG_TEMPLATES_NOVA=${CONFIG_TEMPLATES_NEUTRON[@]} CONFIG_TEMPLATES_NOVA=${CONFIG_TEMPLATES_NEUTRON[@]}
CONFIG_TEMPLATES_OCTAVIA=( CONFIG_TEMPLATES_OCTAVIA=(
"parts/section-database" "parts/section-database"
"parts/database-connection" "parts/database-connection"
"parts/section-identity" "parts/database-connection-settings"
"parts/identity-data" "parts/section-identity"
"parts/identity-data"
"ca-bundle.pem.j2" "ca-bundle.pem.j2"
) )
CONFIG_TEMPLATES_PLACEMENT=( CONFIG_TEMPLATES_PLACEMENT=(
"parts/database-connection" "parts/database-connection"
"parts/section-identity" "parts/database-connection-settings"
"parts/identity-data" "parts/section-identity"
"parts/section-service-user" "parts/identity-data"
"parts/section-service-user"
"ca-bundle.pem.j2" "ca-bundle.pem.j2"
) )

View File

@ -1,3 +1,3 @@
# This file is used to trigger a build. # This file is used to trigger a build.
# Change uuid to trigger a new build on every charms. # Change uuid to trigger a new build on every charms.
4a66cd5b-4da4-433b-a38d-564df526c15d 03381028-42a3-4a2d-9231-7a2642ede8c7

View File

@ -0,0 +1,2 @@
connection_recycle_time = 20
max_pool_size = 2

View File

@ -1,3 +1,3 @@
[database] [database]
{% include "parts/database-connection" %} {% include "parts/database-connection" %}
connection_recycle_time = 200 {% include "parts/database-connection-settings" %}