Skip to content

fix(migrations): let the 2.1.0 relationship type backfill run on utf8mb3 and latin1 MySQL databases - #37189

Merged
manerow merged 1 commit into
mainfrom
fix/mysql-210-utf8mb3-relationship-type
Nov 6, 2026
Merged

manerow merged 1 commit into
mainfrom
fix/mysql-210-utf8mb3-relationship-type

Conversation

@manerow

@manerow manerow commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Issue

No issue. Found while testing PR #37150 on a utf8mb3 database. utf8mb3 databases are real, for example on Google Cloud SQL (issue #28255).

Problem

The 2.1.0 MySQL migration cannot finish on a database whose character set is utf8mb3 or latin1. It stops in postDataMigrationSQLScript.sql with:

COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'utf8mb3'

The failing statement links glossary term relationships to their relationship type (added in PR #28042). It compares the two names case-sensitively with:

ON relationship_type.name COLLATE utf8mb4_bin = relationship.relationType COLLATE utf8mb4_bin

relationship_type_entity is always utf8mb4. But entity_relationship.relationType takes the database character set, and on a utf8mb3 or latin1 database MySQL cannot apply a utf8mb4 collation to it. 2.1.0 is never recorded, so every later migrate fails at the same place.

What this PR changes

One line: relationType is converted to utf8mb4 before the collation is applied.

ON relationship_type.name COLLATE utf8mb4_bin = CONVERT(relationship.relationType USING utf8mb4) COLLATE utf8mb4_bin

The comparison is still case-sensitive, so the result is the same as before on a utf8mb4 database. 2.1.0 is not released yet, so the statement is fixed in place. A database that already ran it on an rc runs it once more: that is safe, because it sets the same values again and keeps existing ones through COALESCE.

How it was tested

On MySQL 8.0:

  • The statement on its own, with entity_relationship on utf8mb3, latin1, utf8mb4_unicode_ci and utf8mb4_0900_ai_ci: the old one fails on utf8mb3 and latin1; the new one works on all four. With a broader and a Broader row, only broader gets linked, as before.
  • The real openmetadata-ops.sh migrate on a fresh utf8mb3 database: before, it stops at this statement; now it finishes 2.1.0. On that database, the new statement links a broader row to its type, and the old one fails.
  • The real migrate on a fresh utf8mb4_0900_ai_ci database still finishes 2.1.0.

I also checked the other COLLATE utf8mb4_* uses in 2.1.0 and in TimeSeriesDAOs. They work on utf8mb3: they apply the collation to a utf8mb4 value (an OAuth column, a CAST, or a JSON_TABLE column, which is always utf8mb4).

@github-actions

github-actions Bot commented Nov 5, 2026

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.

@gitar-bot

gitar-bot Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved

🔴 High risk · Converting names enables a persistent relationship-type backfill on utf8mb3 and latin1 databases; incorrect matches could assign wrong IDs in stored data.

Converts entity_relationship.relationType to utf8mb4 with CONVERT(... USING utf8mb4) before applying the utf8mb4_bin collation in the 2.1.0 relationship type backfill, so the migration completes on utf8mb3 and latin1 MySQL databases. The comparison remains case-sensitive and behaves the same on utf8mb4 databases. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@manerow
manerow merged commit d04552e into main Nov 6, 2026
103 of 105 checks passed
@manerow
manerow deleted the fix/mysql-210-utf8mb3-relationship-type branch November 6, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant