From ca853f5984dc5ad9c0bd5a7d996482f9b08f2137 Mon Sep 17 00:00:00 2001 From: Michal Nasiadka Date: Tue, 29 Sep 2026 12:39:00 +0200 Subject: [PATCH] Stop declaring a MySQL character set on magnum's tables. Some tables declare mysql_DEFAULT_CHARSET='UTF8' (or, via models.table_args(), mysql_charset), others declare no charset at all and inherit the database's own default. From MariaDB 11.5 a bare CHARACTER SET clause stopped resolving to the same collation as the database default (MDEV-25829), so declared and undeclared tables can end up on different collations. nodegroup (undeclared) lands on utf8mb3_general_ci while cluster (declared) lands on utf8mb3_uca1400_ai_ci, and the join between them in nodegroups_v2 aborts every new deployment. Remove the charset declaration everywhere instead of adding it to the tables missing it, so every table consistently defers to the magnum database's own default character set and collation, which deployment tools already set consistently. This removes the per-statement resolution that MDEV-25829 changed, rather than relying on it resolving the same way for every declared table. Existing deployments are unaffected: the migrations that create these tables have already run for them, and this only changes the statement used to create a table for the first time. Related-Bug: #2121797 Change-Id: Ibc7fe2507b75653c79d09f6306a4c8df0b94bd35 Signed-off-by: Michal Nasiadka --- .../2581ebaf0cb2_initial_migration.py | 21 +++++++------------ .../421102d1f2d2_create_x509keypair_table.py | 3 +-- .../456126c6c9e9_create_baylock_table.py | 3 +-- .../ee92b41b8809_create_quotas_table.py | 3 +-- magnum/db/sqlalchemy/models.py | 3 +-- ...ariadb-table-charset-caf1940283bc5fec.yaml | 17 +++++++++++++++ 6 files changed, 28 insertions(+), 22 deletions(-) create mode 100644 releasenotes/notes/mariadb-table-charset-caf1940283bc5fec.yaml diff --git a/magnum/db/sqlalchemy/alembic/versions/2581ebaf0cb2_initial_migration.py b/magnum/db/sqlalchemy/alembic/versions/2581ebaf0cb2_initial_migration.py index d395799f83..27d9b21b89 100644 --- a/magnum/db/sqlalchemy/alembic/versions/2581ebaf0cb2_initial_migration.py +++ b/magnum/db/sqlalchemy/alembic/versions/2581ebaf0cb2_initial_migration.py @@ -45,8 +45,7 @@ def upgrade(): sa.Column('minions_address', sa.Text(), nullable=True), sa.Column('stack_id', sa.String(length=255), nullable=True), sa.PrimaryKeyConstraint('id'), - mysql_ENGINE='InnoDB', - mysql_DEFAULT_CHARSET='UTF8' + mysql_ENGINE='InnoDB' ) op.create_table( 'baymodel', @@ -62,8 +61,7 @@ def upgrade(): sa.Column('dns_nameserver', String(255), nullable=True), sa.Column('apiserver_port', sa.Integer(), nullable=True), sa.PrimaryKeyConstraint('id'), - mysql_ENGINE='InnoDB', - mysql_DEFAULT_CHARSET='UTF8' + mysql_ENGINE='InnoDB' ) op.create_table( 'container', @@ -74,8 +72,7 @@ def upgrade(): sa.Column('name', sa.String(length=255), nullable=True), sa.Column('image_id', sa.String(length=255), nullable=True), sa.PrimaryKeyConstraint('id'), - mysql_ENGINE='InnoDB', - mysql_DEFAULT_CHARSET='UTF8' + mysql_ENGINE='InnoDB' ) op.create_table( 'node', @@ -87,8 +84,7 @@ def upgrade(): sa.Column('image_id', sa.String(length=255), nullable=True), sa.Column('ironic_node_id', sa.String(length=36), nullable=True), sa.PrimaryKeyConstraint('id'), - mysql_ENGINE='InnoDB', - mysql_DEFAULT_CHARSET='UTF8' + mysql_ENGINE='InnoDB' ) op.create_table( 'pod', @@ -103,8 +99,7 @@ def upgrade(): sa.Column('labels', sa.Text(), nullable=True), sa.Column('status', sa.String(length=255), nullable=False), sa.PrimaryKeyConstraint('id'), - mysql_ENGINE='InnoDB', - mysql_DEFAULT_CHARSET='UTF8' + mysql_ENGINE='InnoDB' ) op.create_table( 'service', @@ -119,8 +114,7 @@ def upgrade(): sa.Column('ip', sa.String(length=36), nullable=True), sa.Column('port', sa.Integer(), nullable=True), sa.PrimaryKeyConstraint('id'), - mysql_ENGINE='InnoDB', - mysql_DEFAULT_CHARSET='UTF8' + mysql_ENGINE='InnoDB' ) op.create_table( 'replicationcontroller', @@ -134,7 +128,6 @@ def upgrade(): sa.Column('labels', sa.Text(), nullable=True), sa.Column('replicas', sa.Integer(), nullable=True), sa.PrimaryKeyConstraint('id'), - mysql_ENGINE='InnoDB', - mysql_DEFAULT_CHARSET='UTF8' + mysql_ENGINE='InnoDB' ) # end Alembic commands diff --git a/magnum/db/sqlalchemy/alembic/versions/421102d1f2d2_create_x509keypair_table.py b/magnum/db/sqlalchemy/alembic/versions/421102d1f2d2_create_x509keypair_table.py index ebf781deb7..60c1f98adf 100644 --- a/magnum/db/sqlalchemy/alembic/versions/421102d1f2d2_create_x509keypair_table.py +++ b/magnum/db/sqlalchemy/alembic/versions/421102d1f2d2_create_x509keypair_table.py @@ -43,8 +43,7 @@ def upgrade(): sa.Column('project_id', sa.String(length=255), nullable=True), sa.Column('user_id', sa.String(length=255), nullable=True), sa.PrimaryKeyConstraint('id'), - mysql_ENGINE='InnoDB', - mysql_DEFAULT_CHARSET='UTF8' + mysql_ENGINE='InnoDB' ) op.create_unique_constraint("uniq_x509keypair0uuid", "x509keypair", ["uuid"]) diff --git a/magnum/db/sqlalchemy/alembic/versions/456126c6c9e9_create_baylock_table.py b/magnum/db/sqlalchemy/alembic/versions/456126c6c9e9_create_baylock_table.py index e7512f023e..d227e1748c 100644 --- a/magnum/db/sqlalchemy/alembic/versions/456126c6c9e9_create_baylock_table.py +++ b/magnum/db/sqlalchemy/alembic/versions/456126c6c9e9_create_baylock_table.py @@ -35,6 +35,5 @@ def upgrade(): sa.Column('bay_uuid', sa.String(length=36), nullable=True), sa.Column('conductor_id', sa.String(length=64), nullable=True), sa.PrimaryKeyConstraint('id'), - mysql_ENGINE='InnoDB', - mysql_DEFAULT_CHARSET='UTF8' + mysql_ENGINE='InnoDB' ) diff --git a/magnum/db/sqlalchemy/alembic/versions/ee92b41b8809_create_quotas_table.py b/magnum/db/sqlalchemy/alembic/versions/ee92b41b8809_create_quotas_table.py index 6c96fa63b3..0c6c35edcb 100644 --- a/magnum/db/sqlalchemy/alembic/versions/ee92b41b8809_create_quotas_table.py +++ b/magnum/db/sqlalchemy/alembic/versions/ee92b41b8809_create_quotas_table.py @@ -38,8 +38,7 @@ def upgrade(): sa.Column('resource', sa.String(length=255), nullable=True), sa.Column('hard_limit', sa.Integer(), nullable=False), sa.PrimaryKeyConstraint('id'), - mysql_ENGINE='InnoDB', - mysql_DEFAULT_CHARSET='UTF8' + mysql_ENGINE='InnoDB' ) op.create_unique_constraint( "uniq_quotas0project_id0resource", diff --git a/magnum/db/sqlalchemy/models.py b/magnum/db/sqlalchemy/models.py index 76c804fa5d..67787b7ebb 100644 --- a/magnum/db/sqlalchemy/models.py +++ b/magnum/db/sqlalchemy/models.py @@ -36,8 +36,7 @@ CONF = magnum.conf.CONF def table_args(): engine_name = urlparse.urlparse(CONF.database.connection).scheme if engine_name == 'mysql': - return {'mysql_engine': CONF.database.mysql_engine, - 'mysql_charset': "utf8"} + return {'mysql_engine': CONF.database.mysql_engine} return None diff --git a/releasenotes/notes/mariadb-table-charset-caf1940283bc5fec.yaml b/releasenotes/notes/mariadb-table-charset-caf1940283bc5fec.yaml new file mode 100644 index 0000000000..16889f725b --- /dev/null +++ b/releasenotes/notes/mariadb-table-charset-caf1940283bc5fec.yaml @@ -0,0 +1,17 @@ +--- +fixes: + - | + Magnum's tables no longer declare an explicit ``UTF8`` character set in + their creation migrations, and ``models.table_args()`` no longer passes + ``mysql_charset``. All tables now defer to the ``magnum`` database's own + default character set and collation, as deployment tools already create + it consistently. Previously, some tables declared a bare ``CHARACTER + SET`` and others declared none at all. From MariaDB 11.5 a bare + ``CHARACTER SET`` stopped resolving to the same collation as the + database default (MDEV-25829), so a table that declared the charset and + one that did not could end up with different collations. This broke new + deployments in the ``nodegroups_v2`` migration, which joins the + ``nodegroup`` and ``cluster`` tables, with ``Illegal mix of collations + (utf8mb3_general_ci,IMPLICIT) and (utf8mb3_uca1400_ai_ci,IMPLICIT) for + operation '='``. Existing deployments are unaffected, because the + migrations that create these tables have already run for them.