Skip to content

Fix hard delete failing on MySQL with 'Illegal mix of collations' in FQN cleanup - #38443

Merged
yan-3005 merged 2 commits into
mainfrom
fix/fqn-cleanup-union-collation
Nov 23, 2026
Merged

yan-3005 merged 2 commits into
mainfrom
fix/fqn-cleanup-union-collation

Conversation

@yan-3005

@yan-3005 yan-3005 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #38449

Describe your changes

The hard-delete cleanup added in #38126 (FqnKeyedRowCleanup) 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:

Hash columns Collation
71 (most entity tables) ascii_bin, declared
12 (ai_application_entity, task_entity, …) utf8mb4_0900_ai_ci, table default
query_entity.fqnHash (renamed in 1.2.0 with no collation) the server default

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. The WHERE clause still reads the bare column, so the lookup keeps its index. Postgres is unchanged. No schema change, same pattern as CoreRelationshipDAOs (#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.
  • Reproduced on MySQL 8.4.13 with the 2.0 MySQL schema loaded:
    • --collation-server=utf8mb4_unicode_ci: query_entity.fqnHash is utf8mb4_unicode_ci; the old probe fails with ERROR 1271 Illegal mix of collations for operation 'UNION'.
    • Same server, fixed probe: returns rows from all three tables; EXPLAIN shows type: ref on the hash index.
    • Default server collation: old probe works (why main CI and ITs did not catch it).

Backports: 2.1 and 2.0 to follow.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 4/5

No new behavior failure was found, but the setup method must meet the repository's method-size requirement before merging.

Findings

  1. P2 Test setup is too long ▶

Summary

The PR gives MySQL hash columns a shared collation when building cleanup queries. It leaves the lookup conditions and PostgreSQL queries unchanged.

  • MySQL hard deletes can clean up FQN rows across mixed-collation tables.

Reviews (5) · Last reviewed commit: "Run the FQN-cleanup probes on a real MyS..." · Reviewed by Greptile

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.
@yan-3005
yan-3005 requested a review from a team as a code owner November 23, 2026 08:26
@yan-3005
yan-3005 requested review from manerow and a balanced review from Copilot November 23, 2026 08:26
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This 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 skip-pr-checks label.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.
Copilot AI balanced review requested due to automatic review settings November 23, 2026 08:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@yan-3005
yan-3005 merged commit ebc3283 into main Nov 23, 2026
57 of 63 checks passed
@yan-3005
yan-3005 deleted the fix/fqn-cleanup-union-collation branch November 23, 2026 09:03
yan-3005 added a commit that referenced this pull request Nov 23, 2026
…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)
yan-3005 added a commit that referenced this pull request Nov 23, 2026
…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>
Comment on lines +54 to +55
@BeforeAll
static void startMySql() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Test setup is too long

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hard delete fails on MySQL with 'Illegal mix of collations for operation UNION'

3 participants