Repository navigation
fix(jdbi): read the relationship keyset page as a primary key range on Postgres (backport 2.1 #37582) - #37583
Conversation
|
Local Java test run: PASSED — details
Tests run locally
Broader coverage not executed by this focused run
Why these tests
Impacted, not run locally (2)
Commandsmvn -B package -pl openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=RelationshipKeysetPageSqlTest -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel -Dit.test=EntityRelationshipCleanupIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false |
❌ 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 |
Code Review ✅ Approved 🟡 Medium riskSwitching PostgreSQL relationship pagination to a composite-key range changes cleanup reads; mismatched cursor ordering could skip or repeat relationships. Backports the relationship keyset page fix to 2.1: on Postgres, 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 #37582 to
2.1. No linked issue, by choice. Follow-up to #37561, which gave the 2.1.0 lineage migration step its own fast query.Problem.
getAllRelationshipsAfterreadsentity_relationshipone page at a time. It wrote "rows after the cursor" as fourORed conditions. Postgres cannot use that as a range on the primary key, so each page re-reads the table up to the cursor and a full walk grows with the square of the table. MySQL is not affected.Three callers walk the whole table with it:
relationshipCleanupops command, pages of 1,000 by default;Fix. The query now has one version per engine:
(fromId, toId, relation, relationType) > (...), which Postgres reads as a primary key range.ORquery as today, which MySQL already reads as a range. A row comparison would make MySQL read from the start.Both return the same rows in the same order: all four key columns are
NOT NULL. The decision record gets a v2 amendment that extends its rule to this shared query.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 (v2).
Tests:
Use cases covered
RelationshipKeysetPageSqlTest(new) attaches the real DAO to MySQL and Postgres with the production indexes:relationorrelationType;EntityRelationshipCleanupIT(existing, uses this query) passed on MySQL (in the block below); on Postgres it passed on themainchange (fix(jdbi): read the relationship keyset page as a primary key range on Postgres #37582), which is the same code.The new test repeats the table definition of
LineageEdgePipelineCleanupMigrationTeston purpose: that one is the frozen 2.1.0 schema of a migration step, this one follows the current schema.Backend integration tests
Local Java test run: PASSED
ecfbb1efa72c(baseorigin/2.1)--scope full).Manual testing performed
relationshipCleanup --skip-hierarchy-cleanup(dry run) on a Postgres database with 931k relationships, 2.1 nightly with and without this change:Times include about 5 s of JVM start.
UI screen recording:
Not applicable: backend only.
Checklist:
Fixes #(no issue, by choice)REVIEW.mdonfb3e4a73366(main): no 🔴; this is the same change.6f28ca153a9only rewords the record amendment, as that pass suggested.