Repository navigation
[2.0] Fix hard delete failing on MySQL with 'Illegal mix of collations' (#38443, #37142) - #38442
Conversation
❌ 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 |
| } catch (RuntimeException e) { | ||
| bootFailure = e; | ||
| cached = null; | ||
| tearDown(); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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)
| String hash = | ||
| onMySql ? "CONVERT(" + hashColumn + " USING utf8mb4) COLLATE utf8mb4_bin" : hashColumn; |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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!
| @Testcontainers(disabledWithoutDocker = true) | ||
| @Execution(ExecutionMode.SAME_THREAD) | ||
| class FqnKeyedRowCleanupMySqlTest { |
There was a problem hiding this comment.
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!
| database = | ||
| new GenericContainer<>("mysql:8.4.13") |
There was a problem hiding this comment.
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!
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 areascii_bin, newer tables areutf8mb4_0900_ai_ci, andquery_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, soquery_entity.fqnHashisunicode_cithere and MySQL rejects the union. A customer MySQL on a non-0900_ai_cidefault hits the same 500.Changes
CONVERT(<hash> USING utf8mb4) COLLATE utf8mb4_bin; theWHEREclause keeps the bare column and its index. Postgres unchanged, no schema change. The test conflict was only the DAO host (CollectionDAOon 2.0).mainand2.1, and a UI test server that fails to start is cleaned up instead of left running.Tests
FqnKeyedRowCleanupTeston this branch: Tests run: 14, Failures: 0, Errors: 0.utf8mb4_unicode_ci: the old probe fails withERROR 1271; the fixed probe returns rows andEXPLAINshowstype: refon the hash index.🤖 Generated with Claude Code
The repository's test and style requirements still need to be met before merging.
Findings
Summary
The PR fixes MySQL hard-delete probes when entity hash columns use different collations.
Reviews (7) · Last reviewed commit: "Run the FQN-cleanup probes on a real MyS..." · Reviewed by Greptile