Skip to content

[2.0] Fix hard delete failing on MySQL with 'Illegal mix of collations' (#38443, #37142) - #38442

Merged
yan-3005 merged 3 commits into
2.0from
backport/2.0-ui-it-mysql-collation-37142
Nov 23, 2026
Merged

yan-3005 merged 3 commits into
2.0from
backport/2.0-ui-it-mysql-collation-37142

Conversation

@yan-3005

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

Copy link
Copy Markdown
Contributor

Fixes #38449

Fixes the 2.0 nightly backend failure: on MySQL every hard delete of a taggable entity returned 500 with Illegal mix of collations for operation 'UNION'.

Cause

The hard-delete cleanup from #38230 (backport of #38126) probes every taggable entity table in one UNION ALL. The hash columns do not share a collation: most are ascii_bin, newer tables are utf8mb4_0900_ai_ci, and query_entity.fqnHash (renamed in 1.2.0 with no collation) takes the server default. The 2.0 UI-test MySQL runs with --collation-server=utf8mb4_unicode_ci, so query_entity.fqnHash is unicode_ci there and MySQL rejects the union. A customer MySQL on a non-0900_ai_ci default hits the same 500.

Changes

  1. Backport of Fix hard delete failing on MySQL with 'Illegal mix of collations' in FQN cleanup #38443 (the fix): on MySQL each probe selects CONVERT(<hash> USING utf8mb4) COLLATE utf8mb4_bin; the WHERE clause keeps the bare column and its index. Postgres unchanged, no schema change. The test conflict was only the DAO host (CollectionDAO on 2.0).
  2. Backport of fix(it): run the UI test MySQL on the shipped collation, and clean up a server that fails to start #37142 (test harness): the UI-test MySQL runs on the shipped default collation, as on main and 2.1, and a UI test server that fails to start is cleaned up instead of left running.

Tests

  • FqnKeyedRowCleanupTest on this branch: Tests run: 14, Failures: 0, Errors: 0.
  • Reproduced on MySQL 8.4.13 with the 2.0 schema at utf8mb4_unicode_ci: the old probe fails with ERROR 1271; the fixed probe returns rows and EXPLAIN shows type: ref on the hash index.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 4/5

The repository's test and style requirements still need to be met before merging.

Findings

  1. P2 Container cleanup bypasses required scope ▶
  2. P2 Startup failures lack regression tests ▶
  3. P2 Exception names break repository rules ▶
  4. P2 New declarations omit required final ▶
  5. P2 Expected error text is unnamed ▶
  6. P2 Test is in wrong module ▶

Summary

The PR fixes MySQL hard-delete probes when entity hash columns use different collations.

  • MySQL hard-delete probes now combine hashes with different collations.
  • UI-test servers use MySQL defaults and close stacks that fail to start.

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

… 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)
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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.

Comment on lines +57 to +60
} catch (RuntimeException e) {
bootFailure = e;
cached = null;
tearDown();

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 Startup failures lack regression tests

The new cleanup and fail-fast paths have no regression test. CLAUDE.md requires bug fixes to include a test that fails without the fix. Before merging, add coverage that forces startup to fail, checks that started resources are closed, and calls get() again to check that it does not launch another stack.

Context Used: CLAUDE.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!

bindFixedHostPort(server, FIXED_OM_HOST_PORT, SERVER_PORT);
}
server.start();
} catch (RuntimeException e) {

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 Exception names break repository rules

Both new catch blocks name the exception e, here and in UiTestServer.get(). CLAUDE.md forbids single-letter variables outside short lambdas and loop indices. Before merging, use a descriptive name such as startupFailure in both blocks.

Context Used: CLAUDE.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!

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)
@yan-3005
yan-3005 requested a review from a team as a code owner November 23, 2026 08:28
@yan-3005
yan-3005 requested review from pmbrull and removed request for a team November 23, 2026 08:28
@yan-3005 yan-3005 changed the title [2.0] fix(it): run the UI test MySQL on the shipped collation (#37142) [2.0] Fix hard delete failing on MySQL with 'Illegal mix of collations' (#38443, #37142) Nov 23, 2026
Comment on lines +296 to +297
String hash =
onMySql ? "CONVERT(" + hashColumn + " USING utf8mb4) COLLATE utf8mb4_bin" : hashColumn;

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 New declarations omit required final

The new hash local is assigned only once but lacks final. CLAUDE.md requires final on local variables and parameters that do not change. Add it here and to the new helper parameters and onMySql local in FqnKeyedRowCleanupTest. This repository requirement must be met before merging.

Context Used: CLAUDE.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!

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)
void bareHashColumnsOfMixedCollationsCannotBeUnioned() {
UnableToExecuteStatementException error =
assertThrows(UnableToExecuteStatementException.class, () -> namesakeHashes(false));
assertTrue(error.getMessage().contains("Illegal mix of collations"), error.getMessage());

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 Expected error text is unnamed

The new assertion passes "Illegal mix of collations" directly to contains(). CLAUDE.md forbids raw string literals in contains() calls. Define a named constant for the expected MySQL error text before merging to satisfy this repository requirement.

Context Used: CLAUDE.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!

@yan-3005
yan-3005 merged commit 7e477a4 into 2.0 Nov 23, 2026
64 of 71 checks passed
@yan-3005
yan-3005 deleted the backport/2.0-ui-it-mysql-collation-37142 branch November 23, 2026 09:04
Comment on lines +41 to +43
@Testcontainers(disabledWithoutDocker = true)
@Execution(ExecutionMode.SAME_THREAD)
class FqnKeyedRowCleanupMySqlTest {

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 is in wrong module

FqnKeyedRowCleanupMySqlTest starts MySQL and queries it through the real DAO, so it is an integration test. AGENTS.md requires integration tests to live in openmetadata-integration-tests. Move this test there before merging to meet that repository requirement.

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!

Comment on lines +56 to +57
database =
new GenericContainer<>("mysql:8.4.13")

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 Container cleanup bypasses required scope

startMySql() creates a GenericContainer and relies on stopMySql() to close it. CLAUDE.md requires try-with-resources for all AutoCloseable objects. Put the container and the checks that use it inside a try-with-resources scope. This repository requirement must be satisfied before merging.

Context Used: CLAUDE.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.

2 participants