Skip to content

Part of #38697: Read each lineage edge and each named end once per request - #38866

Open
Vamsi-klu wants to merge 11 commits into
open-metadata:mainfrom
Vamsi-klu:fix/38697-lineage-edge-single-read
Open

Vamsi-klu wants to merge 11 commits into
open-metadata:mainfrom
Vamsi-klu:fix/38697-lineage-edge-single-read

Conversation

@Vamsi-klu

@Vamsi-klu Vamsi-klu commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #39112.

Part of #38697. The issue stays open for the remaining table read and authorization query work, including #38865.

The lineage edge routes read the same stored edge twice in one request, and the routes that name their ends resolved each name twice. The dbt sink calls these routes once per model on every run (add_lineage(check_patch=True) reads the edge by id, then writes it), so every repeated statement is paid once per model.

Root cause

  1. GET by id read the edge row twice. LineageResource.getLineageEdge (LineageResource.java:1184) called LineageRepository.getLineageEdgeEnds (LineageRepository.java:1781, a getRecord) to authorize the ends, then getLineageEdge (LineageRepository.java:1768), which reads the same row again through getLineageDetails (LineageRepository.java:1763, a getRelation).
  2. PUT read the edge row twice. The resource checked the pipeline in authorizeEdgePipeline (LineageResource.java:152) from its own read of the row, then LineageRepository.addLineage read it again with getRecord (LineageRepository.java:247). The OpenLineage endpoint did the same (OpenLineageResource.authorizeEdgePipeline, OpenLineageResource.java:284).
  3. The by name routes resolved each end twice. PUT, PATCH, DELETE and DELETE by source by name resolved both names in the resource to authorize them, then called the repository's addLineageByFQN (LineageRepository.java:307), patchLineageEdgeByFQN (:1841), deleteLineageByFQN (:1314) or deleteLineageBySourceByFQN (:1378), which resolved them again. Each resolution is an uncached findReferencesByNameHashes query (EntityRepository.getReferenceByName, EntityRepository.java:2676).
  4. For a caller that is not an admin, which includes the ingestion bot, each named end was resolved by reference and then loaded again by the authorizer, so a GET by name paid a reference query per end on top of the authorization load.
  5. Column lineage read every column's tags to list column names. getRegistryChildrenNames (LineageRepository.java:1270) asked for the container fields, and asking a table for columns loads its column tags since Fixes 27519: return column tags when columns are requested #34351 (TableRepository.setFields, TableRepository.java:220). Dashboard data models, topics, ML models, API endpoints and worksheets run the same tag prefix query in setFields (Entity.populateEntityFieldTags, Entity.java:1014, queries even when tags were not asked for). That is one or two tag queries per end on every column lineage PUT and PATCH, for names that never use them.

The fix

  1. GET by id reads the edge once (LineageRepository.getStoredEdge), authorizes both ends from that row, and answers from the same row.
  2. PUT (by id and by name) and OpenLineage no longer read the edge in the resource. The pipeline check moved into the repository: the new addLineage(AddLineage, String, Consumer<EntityReference>) reads the row it replaces once, runs the caller's view check on the requested pipeline against that row before it looks up the ends or the pipeline (the order PUT had on main), then resolves the pipeline by the id it checked.
  3. The by name routes resolve each end once, in the new LineageEdgeAccess, and pass the references to the by id repository methods. For a caller that is not an admin the end is loaded with the projection and relation include the lazy authorization context uses, straight from the database rather than the entity cache, and that copy is what the authorizer sees, so the name costs no separate query and a rename on another server is seen right away. An admin is never evaluated against an end, so an admin still gets the cheap reference read. Both branches call the authorizer, so a wrong admin answer can only cost a read, never skip a check.
  4. getRegistryChildrenNames reads the stored entity with find(id, NON_DELETED). Every registry type (table, dashboard data model, topic, container, ML model, pipeline, search index, API endpoint, worksheet) keeps its child containers inline in the stored JSON, and sets the child names in setFullyQualifiedName or prepare before storing; their storageJsonNode overrides strip only the children's tags or owners.

Nothing else moves: no schema, migration, Python, search or impact map change, and no new cache.

Statement counts

From LineageEdgeQueryBudgetIT, per request, on the test commit (the code on main, cd53365) and on this branch, as main → branch (959b639). Each request is sent once to settle the caches and counted the second time, except DELETE, which is counted once. "Edge reads" counts reads of the stored edge row, "Names per end" counts reference queries for one named end, "Column tags" counts column tag queries for both ends, and "Statements" is every statement the request ran. "bot" is the ingestion bot.

Request                          Caller  Edge reads  Names per end  Column tags  Statements
GET by id                        bot     2 → 1       n/a            0 → 0        20 → 19
GET by id                        admin   2 → 1       n/a            0 → 0        2 → 1
GET by name                      bot     1 → 1       1 → 0          0 → 0        21 → 21
GET by name                      admin   1 → 1       1 → 1          0 → 0        3 → 3
PUT by id                        bot     2 → 1       n/a            0 → 0        37 → 36
PUT by id                        admin   2 → 1       n/a            0 → 0        19 → 18
PUT by name                      bot     2 → 1       2 → 0          0 → 0        41 → 38
PUT by name                      admin   2 → 1       2 → 1          0 → 0        23 → 20
PATCH by name                    bot     1 → 1       2 → 0          0 → 0        24 → 22
PATCH by name                    admin   1 → 1       2 → 1          0 → 0        6 → 4
DELETE by name                   bot     1 → 1       2 → 0          0 → 0        41 → 39
DELETE by name                   admin   1 → 1       2 → 1          0 → 0        23 → 21
DELETE by source by name         bot     0 → 0       2 → 0          0 → 0        14 → 13
DELETE by source by name         admin   0 → 0       2 → 1          0 → 0        5 → 4
PUT by id with column lineage    bot     2 → 1       n/a            2 → 0        41 → 36
PUT by id with column lineage    admin   2 → 1       n/a            2 → 0        23 → 18
PATCH by id with column lineage  bot     1 → 1       n/a            2 → 0        24 → 20
PATCH by id with column lineage  admin   1 → 1       n/a            2 → 0        6 → 2

How to read it:

  • GET by id as the ingestion bot goes from 20 statements to 19. The 18 statements left beyond the edge read are the two per end authorization loads, which an admin skips (2 to 1).
  • For the bot, the by name routes no longer issue any reference query. Each named end is read once from the database instead (not from the cache, so a rename on another server can't leave a stale name behind), so PUT by name goes from 41 to 38, PATCH by name from 24 to 22, and GET by name stays at 21.
  • DELETE is counted on its first call. Each end costs one entity load by name in place of the two reference queries.
  • Column lineage writes stop reading column tags (2 to 0) along with the field read around them, so PUT by id with column lineage drops from 41 to 36 and PATCH by id from 24 to 20.

The end to end dbt timing from the issue was not rerun.

Disclosures

  1. The PUT and OpenLineage pipeline view check now runs inside the repository, on its one read of the stored row the write replaces. It still runs before the ends or the pipeline are looked up, so every route answers a pipeline the way it did on main. The decision record "A lineage edge's pipeline must be a pipeline or stored procedure, and linking one needs view access to it" gets a v3 amendment for this.
  2. PUT keeps the denial it had on main: on both PUT routes a caller denied view on pipelines gets 403 whether the newly linked pipeline exists, is soft deleted or never existed, and nothing is written. Only a caller who can view pipelines gets 404 for one that is gone. put_pipelineCallerCannotView_isForbiddenWhetherOrNotItExists and put_pipelineCallerCanViewButIsGone_isNotFound cover both routes.
  3. For a caller that is not an admin, a by name end is read from the database with the authorization projection, never from the entity name cache, because a rename on another server does not evict this server's entry for the old name. That read also evicts this server's cached entry for the end, so the next cached by name read of that entity reloads it once.
  4. Claim 3a in the issue (column tags on fields=columns) is by design: Fixes 27519: return column tags when columns are requested #34351 made that change for GET /tables/{id}?fields=columns returns empty tags arrays for all columns #27519 ("fields=columns returns empty tags arrays"), so this PR does not revert it. It only stops the lineage write path from paying for it.
  5. What remains is the cost fix(security): enforce authorization on sub-resource, listing and admin endpoints #34838 added on purpose: two authorization loads per edge request for a caller that is not an admin, each walking the end's ancestors. This PR keeps that authorization exactly as it is. Making it cheaper is generic EntityRepository work and is tracked in Authorization and inheritance walk the ancestors again for every entity in a request #38865. In the table, the gap between the bot and an admin on the same request (18 statements on GET by id) is that cost.
  6. The issue cites Fixes #35078: authorize VIEW_BASIC on lineage edge-details read endpoints #35140 for the edge read authorization, but Fixes #35078: authorize VIEW_BASIC on lineage edge-details read endpoints #35140 was closed without merging; the authorization came from fix(security): enforce authorization on sub-resource, listing and admin endpoints #34838.
  7. The public *ByFQN methods on LineageRepository and getLineageEdgeEnds have no callers left in this repository. I kept them because Collate may call them; I could not check.

Rebase note

#38139 rewrites the search lineage root code in LineageResource (the authorizeLineageRoot block). This PR leaves that block alone; the nearest hunks are the removed authorizeLineageReference(SecurityContext, String, String, Include) just above it and one new import next to the import #38139 removes. Whichever merges second needs a rebase, which should be mechanical.

Type of change:

  • Improvement

High level design:

Resolution and authorization of named ends move into LineageEdgeAccess, a small package private class next to LineageResource, so the 1,500 line resource does not grow. GET, PUT and PATCH by name resolve both ends before authorizing either, as before, so a missing end is still a 404 for every caller; DELETE still resolves and authorizes from, then to. The pipeline decision is one repository rule (newlyLinkedEdgePipeline) shared by PUT, PATCH and OpenLineage. PUT and OpenLineage check before they resolve the pipeline and PATCH resolves first, both as on main.

Rejected alternatives: reverting the column tags change (brings #27519 back); resolving names for callers that are not admins through the entity name cache (another server's rename can leave a stale name to id mapping until the TTL); a cached by name entity read for every caller (deserializes the entity twice on the bot path, and #28486 moved getReferenceByName to a projection on purpose); warming RequestEntityCache so the lazy context hits it (depends on exact cache keys); a request scoped memo around the ancestor walk (generic code with transaction and staleness hazards, left to the follow up).

Tests:

Use cases covered

  • The ingestion bot and an admin read, write, patch and delete an edge by id and by name with one read of the stored edge and at most one name query per end (none for the bot).
  • Column lineage PUT and PATCH read no column tags.
  • A tag conditioned deny on either end, including a tag inherited from the schema, still refuses the edge read by id and by name.
  • An owner conditioned deny sees direct and inherited owners on PUT, PATCH and DELETE by name, and refuses once the inherited owner is removed.
  • A missing end is 404 before authorization; a soft deleted end is 404 for GET, PUT and PATCH and still deletable; a wrong or unknown type is 404; a pipeline end is authorized like a table.
  • An end renamed on another server is not found by its old name on the by name routes, for the bot and for an admin, even while this server still caches the old name.
  • On PUT by id and by name, a caller denied view on pipelines gets 403 for a live, soft deleted or missing pipeline, and a caller who can view them gets 404 for a missing one; an OpenLineage event with a hidden pipeline fails only its own edges.

Unit tests

  • LineageEdgeAccessTest (new): which copy the authorizer sees for callers that are and are not admins, soft deleted ends, a missing end before a denial, denials.
  • LineageRepositoryTest: the linkEdgePipeline decision table (no pipeline, newly linked, already on the edge, unsupported and new, unsupported and stored), a denied pipeline stores nothing, PUT checks the pipeline before it looks anything up, getStoredEdge and the edge response.
  • LineageResourceGetLineageEdgeAuthorizationTest: GET by id authorizes from the one stored read, and a row without details is 404 after authorization.
  • LineageChildrenNamesTest: child names come from the stored entity for every registry type.

Run locally on 959b639: LineageEdgeAccessTest 7, LineageResourceGetLineageEdgeAuthorizationTest 11, LineageRepositoryTest 60, LineageChildrenNamesTest 13 and ChildFieldResolverTest 24, so 115 tests with 0 failures. On the test commit, with the code on main, LineageChildrenNamesTest errored in 10 of 13 tests and LineageRepositoryTest in 3 of 49 (the column lineage tests whose child names now come from the stored entity).

OpenLineageResource has no unit test; its changed path is covered by openLineageBatch_hiddenPipelineFailsOnlyItsOwnEdges and OpenLineageResourceIT.

Backend integration tests

  • LineageEdgeQueryBudgetIT (new) and LineageEdgeAuthorizationIT (new), including byName_renamedOnAnotherServer_oldNameIsNotFoundForEveryCaller.
  • LineageEdgePipelineAuthorizationIT: both PUT routes with a pipeline the caller cannot view (live, soft deleted, missing), a missing pipeline the caller can view, and an OpenLineage batch with a hidden pipeline.

Run locally on MySQL and Elasticsearch, parallel lane, on 959b639: 5 classes, 136 tests, 0 failures, 3 skipped (the three LineageResourceIT tests that are already disabled on main).

  • LineageEdgeQueryBudgetIT: 16 passed
  • LineageEdgeAuthorizationIT: 8 passed
  • LineageEdgePipelineAuthorizationIT: 11 passed
  • SubResourceAuthorizationIT: 33 passed
  • LineageResourceIT: 68 run, 65 passed, 3 skipped

Before the review fixes (4b7a916), DomainIsolationIT (21), OpenLineageResourceIT (21) and TableColumnTagsIT (4) also passed; they were not rerun on 959b639.

On the test commit, with the code on main, LineageEdgeQueryBudgetIT failed 15 of 16 (only GET by name as admin already met its budget). The rename regression fails on 4b7a916: the bot's GET by the old name answered 200.

Not run here: DomainIsolationIT, OpenLineageResourceIT and TableColumnTagsIT on the latest head, the Postgres and OpenSearch lane and the rest of the merge queue suite, and the nightly scale ITs the planner lists (LineagePayloadScaleIT, LineageScenePerformanceScaleIT).

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

None beyond the tests above.

UI screen recording:

Not applicable: backend only change.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Part of #38697: Read each lineage edge and each named end once per request.
  • My PR links the edge-read work with Fixes #39112 and references 2.1: lineage edge endpoints and table reads make many more DB round trips, slowing dbt ingestion ~65% #38697 as the parent.
  • I commented the code where the reason is not obvious.
  • No JSON Schema change.
  • I added unit and integration tests and listed them above.
  • I reviewed the final diff against REVIEW.md.
  • Decision record: the pipeline record gets a v3 amendment in this PR.
  • I added tests that fail on main (listed in the counts table and under Tests).

@Vamsi-klu
Vamsi-klu requested a review from a team as a code owner November 26, 2026 13:57
@Vamsi-klu

Copy link
Copy Markdown
Contributor Author

Local test results for 4b7a916 (test commit cd53365, fix 0e6da0d, decision record 4b7a916).

Unit tests (service module, run in the same reactor build as the ITs)

  • LineageEdgeAccessTest: 7 passed
  • LineageResourceGetLineageEdgeAuthorizationTest: 11 passed
  • LineageRepositoryTest: 58 passed
  • LineageChildrenNamesTest: 13 passed
  • ChildFieldResolverTest: 24 passed

113 tests, 0 failures.

Integration tests (MySQL and Elasticsearch, parallel lane)

  • LineageEdgeQueryBudgetIT: 16 passed
  • LineageEdgeAuthorizationIT: 7 passed
  • LineageEdgePipelineAuthorizationIT: 9 passed
  • SubResourceAuthorizationIT: 33 passed
  • LineageResourceIT: 68 run, 65 passed, 3 skipped (already disabled on main)
  • DomainIsolationIT: 21 passed
  • OpenLineageResourceIT: 21 passed
  • TableColumnTagsIT: 4 passed

179 tests, 0 failures, 3 skipped.

The same tests against the code on main (test commit only)

  • LineageEdgeQueryBudgetIT failed 15 of 16. The one that passed is GET by name as admin, which already resolved each end once.
  • LineageEdgePipelineAuthorizationIT#linkingMissingPipelineIsNotFound failed: a missing pipeline came back 403, not 404.
  • LineageChildrenNamesTest errored in 10 of 13 tests and LineageRepositoryTest in 3 of 49, because child names were still read through a field read instead of the stored entity.

Statement counts per request (main → branch; each request sent once to warm the caches and counted the second time, DELETE counted once; "bot" is the ingestion bot)

Request                          Caller  Edge reads  Names per end  Column tags  Statements
GET by id                        bot     2 → 1       n/a            0 → 0        20 → 19
GET by id                        admin   2 → 1       n/a            0 → 0        2 → 1
GET by name                      bot     1 → 1       1 → 0          0 → 0        21 → 19
GET by name                      admin   1 → 1       1 → 1          0 → 0        3 → 3
PUT by id                        bot     2 → 1       n/a            0 → 0        37 → 36
PUT by id                        admin   2 → 1       n/a            0 → 0        19 → 18
PUT by name                      bot     2 → 1       2 → 0          0 → 0        41 → 36
PUT by name                      admin   2 → 1       2 → 1          0 → 0        23 → 20
PATCH by name                    bot     1 → 1       2 → 0          0 → 0        24 → 20
PATCH by name                    admin   1 → 1       2 → 1          0 → 0        6 → 4
DELETE by name                   bot     1 → 1       2 → 0          0 → 0        41 → 39
DELETE by name                   admin   1 → 1       2 → 1          0 → 0        23 → 21
DELETE by source by name         bot     0 → 0       2 → 0          0 → 0        14 → 13
DELETE by source by name         admin   0 → 0       2 → 1          0 → 0        5 → 4
PUT by id with column lineage    bot     2 → 1       n/a            2 → 0        41 → 36
PUT by id with column lineage    admin   2 → 1       n/a            2 → 0        23 → 18
PATCH by id with column lineage  bot     1 → 1       n/a            2 → 0        24 → 20
PATCH by id with column lineage  admin   1 → 1       n/a            2 → 0        6 → 2

Not run locally: the Postgres and OpenSearch lane, the rest of the merge queue suite, the nightly scale ITs (LineagePayloadScaleIT, LineageScenePerformanceScaleIT), and the end to end dbt timing from the issue.

@pmbrull pmbrull left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes needed · 2 🔴 · 0 🟡

Blockers ❌ 2 🔴
Nits ✅ none
Tests ❌ gaps in rename freshness and pipeline-authorization ordering coverage
Cross-repo ✅ checked Collate lineage writer callers
Trade-off ✅ none
Auto-approved ➖ changes needed

Thanks for reducing repeated lineage reads and adding integration tests that measure the query count.

  • 🔴 LineageEdgeAccess.java:119 — The local name cache can return a stale entity ID after a rename on another replica. Keep the identity lookup fresh and reuse its result for authorization. Add a non-admin by-name regression with the local cache enabled.
  • 🔴 LineageRepository.java:799 — Both PUT routes now resolve a newly linked pipeline before checking ViewBasic. Preserve the existing PUT denial behavior and use the same edge row for both authorization and persistence. Cover both PUT routes in the authorization tests. Existing review finding

Please keep #38697 open for the remaining table-read and authorization-query work tracked in the PR, including #38865.

What I checked

Traced dbt’s by-name read and write paths, the lineage repository’s edge read, the policy checks, and Collate’s ingestion writer. The query-budget integration tests exercise the intended savings. The current PR checks pass. The author’s reported MySQL and Elasticsearch run covers 179 selected integration tests with three skipped. PostgreSQL and OpenSearch results are still outstanding. PR checks

claude-verdict {"sha":"4b7a916f2ce1561d726c9877ae765afec0cc09cb","recommendation":"request_changes","blocking":2,"nits_to_fix":0,"human_decision":false,"tradeoff":"none","cross_repo":"checked","tests_ok":false}

end.fullyQualifiedName(),
ResourceContext.authorizationFields(repository),
RelationIncludes.fromInclude(Include.ALL),
true);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 With the default cache provider, replicas keep local entries without cross-replica invalidation. A rename committed on one replica can leave a by-name lineage operation on another replica using the previous name-to-ID mapping. Resolve the name with a fresh authorization projection and reuse that entity for the policy check. Add a regression for the non-admin by-name route after a rename with an existing cache entry.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, the non-admin path was trusting this server's name cache. Fixed in acbb2ce: LineageEdgeAccess now reads a non-admin's end straight from the database with the authorization projection (getByName with fromCache=false) and passes that same copy to the policy check. It's still one read per end, and a rename on another replica shows up right away.

The new LineageEdgeAuthorizationIT#byName_renamedOnAnotherServer_oldNameIsNotFoundForEveryCaller renames a metric in the database only, puts the old name back in the cache before each call, and expects 404 on GET, PUT and DELETE by the old name for both the bot and an admin. It failed on the previous head, where the bot's GET came back 200. The fresh read costs the bot two statements on the by name routes (GET 21, PUT 38, PATCH 22), so I updated the budget test and the table in the description.

@Vamsi-klu Vamsi-klu changed the title Fixes #38697: Read each lineage edge and each named end once per request Part of #38697: Read each lineage edge and each named end once per request Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This 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 skip-pr-checks label.

@Vamsi-klu

Copy link
Copy Markdown
Contributor Author

@pmbrull thanks for going through this so carefully. Both fixes are pushed in acbb2ce and 959b639. The rename one is in your inline thread.

For the PUT ordering, addLineage runs the ViewBasic check first again, on the pipeline as requested and against its one read of the replaced row, before it looks up the ends or the pipeline. That's the order main had. So on both PUT routes a caller who can't view pipelines gets 403 for a live, soft deleted or nonexistent pipeline, and only a caller who can view it gets 404. linkingMissingPipelineIsNotFound was asserting the 404 I had introduced, so two parameterized tests over both PUT routes replace it. PATCH keeps main's order, and the decision record amendment is corrected.

I changed the title and description to Part of #38697 so the issue stays open for the remaining table read and authorization work, including #38865. While I was there I reworded a "fix #27519" in the description that GitHub was treating as closing that issue too.

Locally on MySQL and Elasticsearch at 959b639, the five lineage IT classes ran 136 tests with 0 failures (3 skipped, same as main), plus 115 unit tests. I haven't run the Postgres and OpenSearch lane yet, or DomainIsolationIT, OpenLineageResourceIT and TableColumnTagsIT on the new head.

@pmbrull pmbrull left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues found

Blockers ✅ prior code findings resolved
Nits ✅ none
Tests ✅ rename freshness and both PUT authorization paths are covered
Cross-repo ✅ checked Collate lineage callers
Trade-off ✅ fresh name lookups preserve correctness while PUT by name still makes fewer reads
Auto-approved ➖ maintainer review of the authorization changes and passing checks required

Thanks for addressing both findings and keeping #38697 open for the rest of the work. The revised code uses a fresh lookup for named lineage ends and checks permission before resolving a newly linked pipeline on both PUT routes.

Please link a tracking issue for the work this PR completes and keep #38697 as the parent reference. Linking the parent directly would close it when the PR merges. GitHub’s issue linking behavior The backend runner shut down mid-job. Rerun that job and check the red Compatibility status once the head is current. Metadata check · Backend job

What I checked

Read the follow-up diff and the integration tests for a stale cached name and both pipeline authorization routes. The reported head run covers 115 unit tests and 136 MySQL and Elasticsearch integration test cases with three skipped. PostgreSQL and OpenSearch coverage and the other affected integration tests are still outstanding.

claude-verdict {"sha":"959b6394df54dedfd76bd353c66756d5b8fce895","recommendation":"human","blocking":0,"nits_to_fix":0,"human_decision":true,"tradeoff":"holds","cross_repo":"checked","tests_ok":true}

@pmbrull pmbrull assigned mohityadav766 and unassigned pmbrull Nov 27, 2026
@mohityadav766
mohityadav766 self-requested a review November 27, 2026 11:10
@mohityadav766

Copy link
Copy Markdown
Member

@Vamsi-klu can you check the test failures

Copy link
Copy Markdown
Contributor Author

Thanks, Mohit and Pablo. I checked the latest run. Java checkstyle passed, then the runner received a shutdown signal while the service unit tests were still running. Collate Compatibility passed on the current head. GitHub returned a 403 when I tried the rerun. Could someone with repo access retry the backend job?

I linked #39112 for the edge-read work and kept #38697 open for the rest. Could you add #39112 to Shipping when you get a chance?

Main moved addLineage into a locked LineageWriteTransaction. The PUT pipeline
check now runs inside addLineageLocked, right after the edge's guard-row locks
and before the ends are looked up.
mohityadav766 and others added 2 commits December 2, 2026 18:28
Resolve LineageResource conflict with open-metadata#39193: keep main's by-id
authorizeLineageReference overload for delete-by-type, drop the by-name
overload this branch replaced with LineageEdgeAccess, and drop the
EntityInterface import both sides stopped using.
@Vamsi-klu

Copy link
Copy Markdown
Contributor Author

@mohityadav766 @pmbrull the branch is refreshed with main in b40b2d3b0f8 (merge of 602880642f9, no conflicts, no code change), which also restarts the backend job. The last run (46886640322) stopped after 55 minutes with the log cut off in the middle of a test, and I cannot rerun jobs myself.

I ran the tests locally on that merge, on both engines. This covers the Postgres + OpenSearch gap and the three classes that had not been rerun after the two fixes (DomainIsolationIT, OpenLineageResourceIT, TableColumnTagsIT).

Class MySQL + Elasticsearch Postgres + OpenSearch
LineageEdgeQueryBudgetIT 16 passed 16 passed
LineageEdgeAuthorizationIT 8 passed 8 passed
LineageEdgePipelineAuthorizationIT 11 passed 11 passed
SubResourceAuthorizationIT 33 passed 33 passed
LineageResourceIT 69 passed, 3 skipped 69 passed, 3 skipped
DomainIsolationIT 22 passed 22 passed
OpenLineageResourceIT 21 passed 21 passed
TableColumnTagsIT 4 passed 4 passed
Total 187 run, 0 failed, 3 skipped 187 run, 0 failed, 3 skipped

The statement budgets in LineageEdgeQueryBudgetIT hold on Postgres with the same numbers as MySQL, so nothing was loosened.

Unit tests: LineageEdgeAccessTest, LineageResourceGetLineageEdgeAuthorizationTest, LineageRepositoryTest, LineageChildrenNamesTest, ChildFieldResolverTest, 116 passed.

If the runner stops again on the new run, could one of you rerun it? Also, could #39112 be added to Shipping? #38697 stays open as the parent.

@gitar-bot

gitar-bot Bot commented Dec 5, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk 1 closed / 1 findings

Changing lineage-end and pipeline authorization paths could expose restricted edge data or permit links if the loaded policy context differs.

Reduces repeated lineage edge and name reads per request by reading the stored edge once, resolving each named end once, and dropping unneeded column tag reads on column lineage writes. No open issues remain; the previously flagged cached name resolution for non-admin ends has been addressed.

✅ 1 closed
✅ Quality: Cached name resolution for non-admin lineage ends has no record

📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/lineage/LineageEdgeAccess.java:35-43 📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/lineage/LineageEdgeAccess.java:94-108 📄 docs/decisions/2026-11-03-lineage-edge-pipeline-is-restricted-and-view-authorized.md:61-75
LineageEdgeAccess resolves named ends in two ways. Admins get getReferenceByName, a projection read. Every other caller gets repository.getByName(..., true), a cached authorization copy (LineageEdgeAccess.java:94-124). That copy also answers the name. So for non-admin callers, a by-name GET/PUT/PATCH/DELETE can resolve a renamed or re-created FQN from a stale cache entry until the cache TTL expires. Admins and the by-id routes see the change immediately. This choice works against #28486, which moved getReferenceByName to a projection on purpose, and admins and non-admins now see the same FQN differently.

The PR description states the rule only in prose: "Name resolution for non-admin callers goes through the entity name cache, so a rename on another server may be seen up to the cache TTL later." The class Javadoc explains the admin/non-admin split but not this consequence. Nothing in docs/decisions/ records it, and the v3 amendment added here only covers the pipeline check. Because the repository squash-merges, this sentence will be lost.

The record should say: "Lineage by-name routes resolve a non-admin caller's ends from the cached authorization copy, so a rename may be seen up to the entity cache TTL late; admins resolve by projection and are never stale." It could go in a new record or a further amendment to the lineage ADR.

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid duplicate database reads in lineage edge endpoints

3 participants