Skip to content

fix(migration): move the table aliases search-settings backfill to an unreleased 2.0.3 slot - #33413

Merged
ulixius9 merged 6 commits into
mainfrom
migration-table-aliases-v203
Sep 24, 2026
Merged

ulixius9 merged 6 commits into
mainfrom
migration-table-aliases-v203

Conversation

@ulixius9

@ulixius9 ulixius9 commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

The Table.aliases search-settings backfill added by #31829 landed in the 2.0.2 migration slot, which is already released. MigrationWorkflow selects versions by exact set membership against SERVER_CHANGE_LOG, not by a version cutoff — a cluster that has already recorded 2.0.2 never re-applies it, and reprocessing only runs runDataMigration() when the version equals the recorded max. So the migration never runs on precisely the upgraded instances it was written for.

That matters because searchSettings.json is seed data: the additive merge on startup only adds whole missing asset types, so an already-installed cluster keeps its own table entry forever and alias search keeps returning nothing even though the index document and the mapping carry the field. Fresh installs are fine; upgrades are not.

This moves the backfill into a new, unrecorded 2.0.3 slot, so it is picked up exactly once on the next upgrade whichever train the instance is on.

Type of change:

  • Bug fix

High-level design:

  • utils/v202/TableAliasesSearchSettingsMigration → utils/v203/ (pure move, logic unchanged).
  • New mysql/v203/Migration.java and postgres/v203/Migration.java carrying the call, keeping the log-and-continue wrapper (alias search degrading is not worth failing an upgrade over — matches v201's pattern).
  • mysql/v202/Migration.java and postgres/v202/Migration.java are restored byte-for-byte to their pre-Fixes 31512: Ingest SQL Server synonyms as Table.aliases #31829 state: the alias call, its import, and the @Slf4j/lombok import that Fixes 31512: Ingest SQL Server synonyms as Table.aliases #31829 added only to carry the LOG.error are all gone. They keep their own two search-settings repairs, which did ship with 2.0.2.
  • New bootstrap/sql/migrations/native/2.0.3/{mysql,postgres}/ with empty schemaChanges.sql + postDataMigrationSQLScript.sql — this is a data migration only, same shape as 2.0.1. The directory is what MigrationWorkflow.getMigrationFilesFromPath enumerates, so without it the Java class is never reached.

No behaviour change for a fresh install (the seed already carries aliases); the only difference is when an upgraded cluster gets the backfill — which is now "at all".

Tests:

  • migration/utils/v203/MigrationWiringTest (new) — pins that the 2.0.3 directory resolves to org.openmetadata.service.migration.{mysql,postgres}.v203.Migration and that both dialects ship the two SQL files. MigrationFile falls back to a no-op default class when the package does not match the directory name, silently skipping the whole data migration with no error, so this is the failure mode worth pinning. The existing v202 wiring test is kept — v202 still has two live repairs.
  • migration/utils/v203/TableAliasesSearchSettingsMigrationTest — moved with the class, unchanged.
$ mvn -pl openmetadata-service test -Dtest='MigrationWiringTest,TableAliasesSearchSettingsMigrationTest,TableIndexTest'
Tests run: 11, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

mvn -pl openmetadata-service -am install -DskipTests and mvn -pl openmetadata-service spotless:check both pass.

Unit tests

  • I added unit tests for the new/changed logic.

Backend integration tests

  • Not applicable — no API surface changes.

Playwright (UI) tests

  • Not applicable — no UI changes.

Checklist:

  • I have read the CONTRIBUTING document.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: no schema change here; this is migration wiring only.
  • I have added tests and listed them above.

🤖 Generated with Claude Code

RetriggerConfidence Score: 4/5

The PR is not yet safe to merge because a failed aliases backfill can still be recorded as successfully applied, and an explicit Java finality requirement remains unsatisfied.

Findings

  1. P1 Failed backfill is recorded ▶
  2. P2 Unchanged local lacks final ▶
Summary

Moves the table-aliases search-settings backfill from the already-released 2.0.2 migration slot into 2.0.3 so upgraded installations can apply it.

  • Removes the backfill wiring from both v202 database migrations.
  • Adds the backfill to both v203 database migrations.
  • Moves the migration utility and its tests into the v203 package.
  • Adds migration-directory and class-resolution coverage for both database dialects.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Upgrade[Upgraded installation] --> V203[Select unrecorded 2.0.3 migration]
  V203 --> MySQL[MySQL v203 migration]
  V203 --> PostgreSQL[PostgreSQL v203 migration]
  MySQL --> Backfill[Add aliases search settings]
  PostgreSQL --> Backfill
  Backfill --> Persist[Persist updated table search configuration]
Loading

Reviews (6) · Last reviewed commit: "Merge branch 'main' into migration-table..."

…to 2.0.3

2.0.2 is already released, and MigrationWorkflow selects versions by exact
set membership against SERVER_CHANGE_LOG: a cluster that has already recorded
2.0.2 never re-applies it, so a data migration retro-fitted into that slot
never runs and alias search keeps returning nothing on exactly the upgraded
instances it was written for (the searchSettings.json seed only reaches fresh
installs).

2.0.3 is unrecorded everywhere, so it is picked up exactly once on the next
upgrade whichever train the instance is on. v202 keeps its own two
search-settings repairs, which shipped with 2.0.2, and is otherwise restored
byte-for-byte to its pre-aliases state.

Adds the native 2.0.3 SQL directories for both engines (empty, like 2.0.1 --
this is a data migration only) and a MigrationWiringTest for 2.0.3, because a
mismatch between the directory name and the Java package silently resolves to
the default no-op migration class with no error.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI lite review requested due to automatic review settings September 16, 2026 11:33
@ulixius9
ulixius9 requested a review from a team as a code owner September 16, 2026 11:33

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 reached their quota limit.

@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 +32 to +36
try {
addAliasesSearchSettings();
} catch (Exception e) {
LOG.error("v203: failed to backfill the table 'aliases' search settings", 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.

P1 Failed backfill is recorded

If reading or writing the search settings fails, this catch logs the error and returns normally. The migration workflow then records 2.0.3 as successfully applied even though the aliases were not persisted. Because this data-only migration has no new SQL statements, later reprocessing skips it, leaving alias search broken on that cluster. The PostgreSQL implementation has the same issue.

Suggested change
try {
addAliasesSearchSettings();
} catch (Exception e) {
LOG.error("v203: failed to backfill the table 'aliases' search settings", e);
}
addAliasesSearchSettings();

main added a v203 data migration (glossary term relation cardinality
backfill) in the same package this branch created for the table aliases
search-settings backfill. Keep both: run the glossary backfill first,
then the guarded aliases backfill.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

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 reached their quota limit.

@Override
@SneakyThrows
public void runDataMigration() {
MigrationUtil migrationUtil = new MigrationUtil(handle);

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 Unchanged local lacks final

migrationUtil is initialized once and never reassigned, but it is declared without final. The PostgreSQL implementation repeats this at line 21. This violates the repository directive requiring unchanged Java locals and parameters to be marked final, so the requirement must be satisfied before merging.

Suggested change
MigrationUtil migrationUtil = new MigrationUtil(handle);
final MigrationUtil migrationUtil = new MigrationUtil(handle);

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!

@greptile-apps

greptile-apps Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff

These findings sit on lines the diff does not cover, so they could not be posted inline. Each one leaves this list once its file changes.

  • P2 Test documents wrong version openmetadata-service/src/test/java/org/openmetadata/service/migration/utils/v203/TableAliasesSearchSettingsMigrationTest.java:29 ▶

    This moved test still says it covers the 2.0.2 migration, which contradicts its v203 package and the purpose of this change. That stale description could cause future migration maintenance to attribute the backfill to the released slot it was specifically moved away from.

    /**
     * Covers the merge the 2.0.3 migration applies to a stored search-settings document: the alias
     * fields have to reach an existing {@code table} configuration without disturbing what an operator
     * already put there.
     */
    

    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!

main added two more v203 data migrations (the DataConsumerPolicy
CreateTask-Rule repair) alongside the glossary cardinality backfill this
branch already merged with. Keep all of them: the policy repairs run
first, then the guarded table aliases search-settings backfill.

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 reached their quota limit.

main added a third v203 data migration (removeServiceEdgesBypassingPipeline)
in the same runDataMigration() as the table aliases backfill. Keep both:
the service-edge cleanup runs with the other main migrations, then the
guarded aliases search-settings backfill.

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 reached their quota limit.

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 reached their quota limit.

@gitar-bot

gitar-bot Bot commented Sep 23, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · Relocates an additive aliases-search-settings backfill into the 2.0.3 upgrade migration.

Moves the table-aliases search-settings backfill from the already-released 2.0.2 migration slot into the unreleased 2.0.3 slot so it runs on upgraded instances. Restores v202 migrations to their pre-backfill state, wires the backfill into v203 for both MySQL and PostgreSQL dialects, and adds comprehensive wiring tests. No issues found.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

🤖 Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

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

This branch was previously deployed

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

Labels

Ingestion 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.

3 participants