Repository navigation
Conversation
…llation before it changes anything
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
…e drop-create drops the tables
Code Review ✅ Approved 1 closed / 1 findings🔴 High risk · Because this gates schema migrations and destructive drop-create operations, an incorrect collation result could block upgrades or table recreation. Adds a preflight check to ✅ 1 closed✅ Bug: drop-create drops every table before the collation check runs
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Issue
No issue. Follow-up to PR #37142, which found MySQL collations that cannot finish the 2.1.0 migration.
Problem
OpenMetadata's MySQL tables use two collations:
utf8mb4_0900_ai_ciin their definitionentity_relationshipandentity_extension, take the database defaultMySQL refuses to compare two different non-binary collations of the same character set. So on a default such as
utf8mb4_unicode_ciorutf8mb4_general_ci, migrations and queries that compare ids across the two groups fail withIllegal mix of collations. Today such a database fails halfway through an upgrade, with a raw SQL error.What this PR changes
migrateanddrop-createnow check the MySQL database before changing anything:migratechecks the database default and the id columns that migrations compare:entity_relationship.fromId,entity_relationship.toIdandentity_extension.id. It reads the columns, becauseALTER TABLE ... COLLATEwithoutCONVERT TOchanges only the table default.drop-createchecks only the database default, before it drops anything. It rebuilds the tables from that default, so drifted tables get repaired.Only a utf8mb4 collation other than
utf8mb4_0900_ai_cior a_binone is reported. The command then exits 1 and lists each clashing item with how to fix it.Other columns, such as
entity_extension.extension(ASCII on some databases), are not checked. PostgreSQL is not affected.Who this can stop
openmetadata_dbwithout a collation, so it gets MySQL 8's default._bindatabases: not stopped. MySQL converts the other character set to utf8mb4, and a_bincollation wins the comparison. To finish 2.1.0, utf8mb3 and latin1 also need PR fix(migrations): let the 2.1.0 relationship type backfill run on utf8mb3 and latin1 MySQL databases #37189.utf8mb4_general_ciandutf8mb4_unicode_cidatabases: stopped. They fail the 2.1.0 upgrade anyway; the check makes them fail first, with a fix. We don't yet know if any exist: a database keeps the collations it was created with.A row needs fixing only if
db_defaultorcolumn_collationis a utf8mb4 collation other thanutf8mb4_0900_ai_cior a_binone.How it was tested
DELETEon MySQL 8.0 fails with ERROR 1267 on five non-binary utf8mb4 collations, includingunicode_ciandgeneral_ci, and works on utf8mb3, latin1, ascii and_bincollations.MySqlCollationCheckTest(Testcontainers, 14 tests) covers each case above, drifted columns,ALTER TABLE ... COLLATE, an ASCIIextensioncolumn, and drop-create ignoring drifted tables.openmetadata-ops.sh: on autf8mb4_unicode_cidefault,migratecreates no tables anddrop-createdrops nothing; on a correct default with drifted columns,migratestops anddrop-createrebuilds and finishes 2.1.0; on utf8mb3, the check passes.GuardedBlockMySqlExecutionTeststill passes.