Repository navigation
Fix hard delete failing on MySQL with 'Illegal mix of collations' in FQN cleanup - #38443
Conversation
The hard-delete cleanup from #38126 probes every taggable entity table in one UNION ALL. MySQL rejects a UNION whose columns have different collations, and an install's hash columns do not share one: most are ascii_bin, the newer tables declare utf8mb4_0900_ai_ci, and query_entity.fqnHash (renamed in 1.2.0 without a collation) takes the server default. On a server whose default is not utf8mb4_0900_ai_ci, every hard delete of a taggable entity fails with "Illegal mix of collations for operation 'UNION'". On MySQL each probe now selects CONVERT(hash USING utf8mb4) COLLATE utf8mb4_bin. The WHERE clause still reads the bare column, so the lookup keeps its index. No schema change.
❌ 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 |
The SQL-string test cannot catch the collation error. This one starts MySQL with utf8mb4_unicode_ci as the server default and three tables on the collations an install mixes (ascii_bin, utf8mb4_0900_ai_ci, server default). The bare-column union fails with 'Illegal mix of collations'; the namesake and nested probes return the hash from every table.
…s' in FQN cleanup (#38443) (#38444) * Select FQN-cleanup probe hashes in one collation on MySQL The hard-delete cleanup from #38126 probes every taggable entity table in one UNION ALL. MySQL rejects a UNION whose columns have different collations, and an install's hash columns do not share one: most are ascii_bin, the newer tables declare utf8mb4_0900_ai_ci, and query_entity.fqnHash (renamed in 1.2.0 without a collation) takes the server default. On a server whose default is not utf8mb4_0900_ai_ci, every hard delete of a taggable entity fails with "Illegal mix of collations for operation 'UNION'". On MySQL each probe now selects CONVERT(hash USING utf8mb4) COLLATE utf8mb4_bin. The WHERE clause still reads the bare column, so the lookup keeps its index. No schema change. (cherry picked from commit 4f9ccf8) * Run the FQN-cleanup probes on a real MySQL with mixed hash collations The SQL-string test cannot catch the collation error. This one starts MySQL with utf8mb4_unicode_ci as the server default and three tables on the collations an install mixes (ascii_bin, utf8mb4_0900_ai_ci, server default). The bare-column union fails with 'Illegal mix of collations'; the namesake and nested probes return the hash from every table. (cherry picked from commit 5316487)
…s' (#38443, #37142) (#38442) * fix(it): run the UI test MySQL on the shipped collation, and clean up a server that fails to start (#37142) * fix(it): stop a containerized UI test server that fails to start, and fail fast after it * fix(it): run the containerized UI test MySQL on the collation OpenMetadata ships with * style(it): apply spotless (cherry picked from commit 74b0529) * Select FQN-cleanup probe hashes in one collation on MySQL The hard-delete cleanup from #38126 probes every taggable entity table in one UNION ALL. MySQL rejects a UNION whose columns have different collations, and an install's hash columns do not share one: most are ascii_bin, the newer tables declare utf8mb4_0900_ai_ci, and query_entity.fqnHash (renamed in 1.2.0 without a collation) takes the server default. On a server whose default is not utf8mb4_0900_ai_ci, every hard delete of a taggable entity fails with "Illegal mix of collations for operation 'UNION'". On MySQL each probe now selects CONVERT(hash USING utf8mb4) COLLATE utf8mb4_bin. The WHERE clause still reads the bare column, so the lookup keeps its index. No schema change. (cherry picked from commit 4f9ccf8) * Run the FQN-cleanup probes on a real MySQL with mixed hash collations The SQL-string test cannot catch the collation error. This one starts MySQL with utf8mb4_unicode_ci as the server default and three tables on the collations an install mixes (ascii_bin, utf8mb4_0900_ai_ci, server default). The bare-column union fails with 'Illegal mix of collations'; the namesake and nested probes return the hash from every table. (cherry picked from commit 5316487) --------- Co-authored-by: Adrià Manero <adria.estivill@getcollate.io>
| @BeforeAll | ||
| static void startMySql() { |
There was a problem hiding this comment.
startMySql() has about 23 nonblank code lines. The Java guide requires methods to stay around 15 lines and do one thing. Split container setup from the JDBI connection and table setup to satisfy this repository requirement before merging.
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Fixes #38449
Describe your changes
The hard-delete cleanup added in #38126 (
FqnKeyedRowCleanup) probes every taggable entity table in oneUNION ALL. MySQL rejects aUNIONwhose columns have different collations, and an install's hash columns do not share one:ascii_bin, declaredai_application_entity,task_entity, …)utf8mb4_0900_ai_ci, table defaultquery_entity.fqnHash(renamed in 1.2.0 with no collation)On a MySQL server whose default collation is not
utf8mb4_0900_ai_ci, every hard delete of a taggable entity fails with a 500:Illegal mix of collations for operation 'UNION'. The 2.0 nightly hit this; its UI-test MySQL runs with--collation-server=utf8mb4_unicode_ci.On MySQL each probe now selects
CONVERT(<hash> USING utf8mb4) COLLATE utf8mb4_bin AS hash. TheWHEREclause still reads the bare column, so the lookup keeps its index. Postgres is unchanged. No schema change, same pattern asCoreRelationshipDAOs(#38112).Tests
FqnKeyedRowCleanupTest: MySQL cases now expect the collation-safe probe.mvn -B package -pl :openmetadata-service -am -Dtest=FqnKeyedRowCleanupTest: Tests run: 14, Failures: 0, Errors: 0.--collation-server=utf8mb4_unicode_ci:query_entity.fqnHashisutf8mb4_unicode_ci; the old probe fails withERROR 1271 Illegal mix of collations for operation 'UNION'.EXPLAINshowstype: refon the hash index.Backports: 2.1 and 2.0 to follow.
🤖 Generated with Claude Code
No new behavior failure was found, but the setup method must meet the repository's method-size requirement before merging.
Findings
Summary
The PR gives MySQL hash columns a shared collation when building cleanup queries. It leaves the lookup conditions and PostgreSQL queries unchanged.
Reviews (5) · Last reviewed commit: "Run the FQN-cleanup probes on a real MyS..." · Reviewed by Greptile