Repository navigation
fix(migrations): read the 2.1.0 lineage clean-up scan as a primary key range on Postgres (backport 2.1 #37560) - #37561
Conversation
…y range on Postgres
❌ 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 |
|
Local Java test run: PASSED — details
Tests run locally
Broader coverage not executed by this focused run
Commandsmvn -B package -pl openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=IngestionPipelineMigrationEntryPointTest,LineageEdgePipelineCleanupMigrationTest,MigrationTest -Dsurefire.failIfNoSpecifiedTests=false |
Code Review ✅ Approved 🔴 High riskRewrites lineage relationship JSON during a data migration; an incorrect key or selection could clear or alter stored lineage metadata. Replaces the shared lineage cleanup scan in VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Describe your changes:
Cherry-pick of #37560 to
2.1. No linked issue, by choice.Problem. The 2.1.0 step that clears non-pipeline references from lineage edges (
LineageEdgePipelineCleanupMigration) reads all ofentity_relationship, 500 rows at a time. Its query wrote the cursor as fourORed conditions. Postgres cannot use that as a range on the primary key, so every batch re-reads the table up to the cursor and the step grows with the square of the table. One batch mid-table on 931k rows: 923 ms.Fix. The step carries its own SQL instead of the shared
getAllRelationshipsAfter:(fromId, toId, relation, relationType) > (...), which is a primary key range (0.6 ms for that batch).ORquery, which MySQL already reads as a range.relation = 13filter made Postgres use another index and sort each batch.UPDATEon its full key. The old sharedinsertalways wroterelationType = '', so it could overwrite or add the wrong row.The shared query and its other callers are out of scope and unchanged. The step keeps its
runOnceguard.Type of change:
High-level design:
Recorded in ADR:2026-11-11-a-composite-keyset-page-is-a-row-comparison-on-postgres-and-an-or-chain-on-mysql.
Tests:
Use cases covered
Unit tests
LineageEdgePipelineCleanupMigrationTest(rewritten),IngestionPipelineMigrationEntryPointTest(updated).Backend integration tests
Local Java test run: PASSED
119a15e0c7c3(baseorigin/2.1)--scope full).Manual testing performed
migrateon restored 2.0.7 dumps, with the 2.1 nightly and the same nightly plus only this change:migrate433 s)migrate84 s)On MySQL the scan alone is unchanged (about 3.3 s both ways); the extra second is the 7,000 keyed
UPDATEs. Rerun on Postgres: with the step's marker removed, the fix cleared 0 and the table checksum did not change.UI screen recording:
Not applicable: backend migration only.
Checklist:
Fixes #(no issue, by choice)REVIEW.mdonc99c51d3e86(main); this is the same change. Answered: the shared query stays slow for its other callers; out of scope, named in the record.