#34382·OpenMetadata

Migrations run pending native versions before pending extension versions on a partly migrated database

Author: manerowCreated Oct 1, 2026Updated Oct 1, 2026
Labelsbugbackend

Problem

When the database already has some migration history, migrate runs every pending native (OpenMetadata) migration before any pending extension migration, whatever their versions. On an empty database the order is different: all migrations run in one version order, with a native version just before the extension version of the same number.

So the order depends on whether the database is empty. Any native migration that relies on the result of an older extension migration breaks when that extension migration is still pending.

This is what happens on a Collate database today. In 2.0.0, OpenMetadata took over the knowledge_center table from Collate (2.0.0 postgres schemaChanges.sql). That migration assumes a Collate database has already been through 1.6.0-collate, which renames nameHash to fqnHash. When 1.6.0-collate is still pending, 2.0.0 runs first and fails on Postgres:

Failed to run sql: [CREATE INDEX IF NOT EXISTS index_knowledge_center_deleted ON knowledge_center (fqnHash, deleted)] due to [org.jdbi.v3.core.statement.UnableToExecuteStatementException: org.postgresql.util.PSQLException: ERROR: column "fqnhash" does not exist ...]
    at org.openmetadata.service.migration.api.MigrationProcessImpl.performSqlExecutionAndUpdate(MigrationProcessImpl.java:144)
    at org.openmetadata.service.migration.api.MigrationProcessImpl.runSchemaChanges(MigrationProcessImpl.java:101)
    at org.openmetadata.service.migration.api.MigrationWorkflow.runSchemaChanges(MigrationWorkflow.java:508)
    at org.openmetadata.service.migration.api.MigrationWorkflow.runMigrationWorkflows(MigrationWorkflow.java:459)

How it was hit

A new install of Collate 2.0.3 on Postgres:

  1. The first migrate ran on an empty database, so it used the single version order. 1.2.0-collate created knowledge_center with a nameHash column. The run then stopped in the 1.5.0 data migration for an unrelated reason: the Helm chart did not mount a config file that the pipeline service client needs (open-metadata/openmetadata-helm-charts#543).
  2. After that was fixed, the second migrate found migration history, so it queued all pending native versions (1.5.0 up to 2.0.3) ahead of all pending extension versions (1.5.0-collate onwards). 2.0.0 ran before 1.6.0-collate and failed with the error above.

From reading the code (not reproduced), a Collate database upgraded from a version older than 1.6.0 straight to 2.0.x takes the same path and fails the same way.

Steps to reproduce

Reproduced with the Collate 2.0.3 server image on Postgres 16, running ./bootstrap/openmetadata-ops.sh migrate directly (no Kubernetes needed):

  1. On an empty database, make the 1.5.0 data migration fail. Here: PIPELINE_SERVICE_CLIENT_CLASS_NAME=io.collate.pipeline.argo.ArgoServiceClient with ARGO_INGESTION_WORKFLOW_SPEC_FILE_PATH pointing at a file that doesn't exist. No Argo server is needed, because the client's startup connectivity check only logs a failure. server_change_log then ends at 1.4.7 and 1.4.0-collate, and knowledge_center still has namehash.
  2. Create the file and run migrate again. It runs 1.5.0, 1.5.6, … 1.13.4, 2.0.0 with no extension version in between, although 1.5.0-collate to 1.6.0-collate are pending, and fails at 2.0.0 with the error above. Every further run fails straight away at 2.0.0.
  3. For comparison, drop the database and run migrate once with the file in place. It uses the single order (… 1.6.0, 1.6.0-collate, 1.6.1-collate … 2.0.0, 2.0.0-collate …), completes, and validate passes.

With a fix, step 2 should complete like step 3.

Where in the code

With no history, resolveApplyMigrations uses the full list sorted by version (MigrationWorkflow.java#L303). With history it calls getMigrationsToApply (L312-L318), which adds the pending native list and then the pending extension list.

Expected behaviour

Pending migrations run in the same order as on an empty database: one version order across native and extension migrations. Retrying after a failed run, or upgrading across several versions, should not change that order.

Tests to include with the fix

  • A unit test for this exact case in MigrationWorkflowTest. The class already builds temporary native and extension migration folders and mocks the migration history. Set up native 1.5.0 and 2.0.0 and extension 1.2.0-collate and 1.6.0-collate, with only 1.2.0-collate already run. The pending order must be 1.5.0, 1.6.0-collate, 2.0.0. Today it is 1.5.0, 2.0.0, 1.6.0-collate, so the test fails before the fix.
  • A general check of the rule. Take a list of mixed native and extension versions, and for every point where a run could stop, check that the pending list is the rest of the empty-database order (with no new SQL in already-run versions, so the reprocessing rule does not kick in). This covers every partial state, not only this one. It also means the empty-database runs in CI, the integration tests and e2e cover retries too, because both follow the same order.

A real "stop halfway and retry" test against a live database is not needed. It takes about 6 minutes per run, and the SQL in each migration is already run by every empty-database test.

Related issues

  • open-metadata/openmetadata-helm-charts#543: the chart does not mount custom-config in run-db-migrations, which made the first run fail and left the database partly migrated.
  • #34392: data migrations create the pipeline service client even when they have nothing to delete, which is why that missing mount could stop a new install.

Source: open-metadata/OpenMetadata