Skip to content

Fixes #38698: Draw Dashboard to Chart lineage on the server instead of in ingestion - #38914

Merged
yan-3005 merged 16 commits into
open-metadata:mainfrom
Vamsi-klu:codex/38698-dashboard-chart-lineage
Dec 4, 2026
Merged

yan-3005 merged 16 commits into
open-metadata:mainfrom
Vamsi-klu:codex/38698-dashboard-chart-lineage

Conversation

@Vamsi-klu

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

Copy link
Copy Markdown
Contributor

Describe your changes

Fixes #38698

In 2.1, dashboard ingestion drew the Dashboard → Chart lineage edges itself. For every dashboard it flushed the sink, read the dashboard back and wrote one lineage request per chart, which made dashboard ingestion much slower. The server already stores the same set as the Dashboard HAS Chart relationship, so ingestion was copying server data back to the server.

Following the backend discussion, this PR now moves those edges to the server and drops the batch API proposed earlier in this PR.

Type of change

  • Bug fix
  • Improvement

Decision (ADR:2026-12-04-the-server-owns-dashboard-to-chart-lineage)

The server keeps one Dashboard → Chart lineage edge for every chart a dashboard holds, and ingestion no longer draws them.

  • Source. The edges carry a new DashboardChartLineage source. An overrideLineage run deletes the DashboardLineage edges into a chart before writing its own. The server only redraws an edge when the dashboard's charts change, so a shared source would lose the edge for good.
  • When. A dashboard's edges are reconciled when it is created (single or bulk), and when its charts change through an update or a CSV import. The reconcile reads the charts from the database and adds the missing edges. It then reads them again and removes its own edges to charts the dashboard no longer holds, so the later of two racing saves decides the edges.
  • Other writers. An existing edge between the dashboard and the chart with any other source is neither replaced nor removed.
  • Authorization. The edges follow the dashboard's chart membership, which the dashboard write already authorized, so the server writes them without a separate lineage permission check.
  • Ordering. The edges are written after the dashboard's transaction commits, each as its own lineage write, because a lineage write takes its guard locks first in its own transaction (ADR:2026-11-26-domain-lineage-rollup-writers-lock-guard-rows-in-one-order).
  • Existing data. The 2.1.2 migration adds the missing edges and moves the edges the 2.1 stage wrote (carrying only the DashboardLineage source) to the new source.

How overrideLineage behaves

Nothing changes for connector lineage. An override still deletes the edges of the source its connector writes and redraws them, as in ADR:2026-11-09-dbt-override-lineage-deletes-when-the-manifest-declares-no-parent and ADR:2026-11-25-direct-chart-lineage-is-a-dashboard-pipeline-option. The sink and lineage code paths are unchanged.

The server's Dashboard → Chart edges are no longer connector edges, so an override leaves them alone. They still never go stale: when ingestion saves a dashboard, the server removes the edge of any chart that left it, on every run.

Changes

  • DashboardChartLineageSync is wired into DashboardRepository (create, bulk create and chart changes). It writes through LineageRepository, so search, RDF, domain rollups and change events all apply.
  • LineageSource gains DashboardChartLineage (schema, generated TS, UI label).
  • The v212 data step DashboardChartLineageBackfill works on rows only, for MySQL and Postgres.
  • Ingestion: removed the yield_dashboard_chart_lineage stage. The tableau and ssrs ingestion ITs now expect the new source.
  • Removed from the earlier version of this PR: the batch endpoint, /capability, the 4 batch schemas, the search and DAO additions, and the ingestion batch client.

Upgrade note: run ./bootstrap/openmetadata-ops.sh reindex --entities=chart after upgrading, so the lineage views show the backfilled edges. The 2.1.2 lineage rebuild steps already need a reindex.

Tests

Suite MySQL + ES Postgres + OS
DashboardChartLineageIT (API create, PATCH, PUT, bulk create, another writer's edge kept, override delete keeps the edge, search shows the edge) 7 / 0 7 / 0
DashboardChartLineageBackfillMigrationIT (missing edge, stage edge adopted, query/manual edges kept, released chart untouched, no-op second run) 2 / 0 2 / 0
DashboardResourceIT (regression) 240 / 0, 21 skipped 240 / 0, 21 skipped
  • Unit tests: DashboardChartLineageBackfillTest 9 / 0, MigrationArchitectureTest 2 / 0, MigrationTest pass.

  • Ingestion unit tests (dashboard topology and lineage edge cache): 1645 passed.

  • The migration IT caught one bug, now fixed: JsonNode.isEmpty() is true for scalars, so an edge with a sqlQuery would have been taken as a stage edge.

  • Playwright on a local server built from this branch, with sample data loaded: LineageInteraction, LineageControls and LineageRightPanel (Basic) 45 / 45; Dashboards.spec.ts 4 / 4 (chromium + Basic). The sample data's dashboards got one DashboardChartLineage edge per chart.

  • Browser tests: DataProductAssetsOutputPorts timed out on this PR because data contract suites earlier in the shard left toasts over the Delete button (the browser tests run with isolate:false). The three data product ports suites now run the shared closeToasts helper before each test. Reproduced locally, then 49 / 49 with the fix.

  • Merged main: Fixes 5974, 5972, 5977: migrate Redash, PowerBI and Tableau CLI E2E to v2 #39762 had changed the removed stage and added a PowerBI override of it. Both are removed here, because the server now draws the edges for every dashboard of a bulk write.

Live verification

A local server built from this branch (MySQL + Elasticsearch) ran the real tableau and ssrs ingestion workflows: a first run, a rerun and an overrideLineage rerun. Both runs passed 26 / 26.

The same workflows on the same server, compared between main's ingestion and this branch:

API calls during the run main this PR
All 475 388
GET /dashboards/name/… 81 50
GET /lineage/getLineageEdge/… 62 14
DELETE /lineage/chart/{id}/type/DashboardLineage (override) 8 0

Main's override run sent those 8 deletes against the server's edges, and its override test still passed. A real override run leaves them in place.

A dashboard created through the REST API (no ingestion) with 3 charts:

Dashboard created through the API gets one edge per chart

After a PUT that drops top_customers from the dashboard, its edge is removed:

Removing a chart removes its edge

After DELETE /lineage/chart/{id}/type/DashboardLineage, the call an override run makes, the edges stay:

An override delete keeps the server's edges

Backend integration tests

UI screen recording

Server and ingestion change. The screenshots above show the lineage view.

Checklist

  • Read the contribution guide and reviewed the change against REVIEW.md.
  • Integration tests for the new behavior and the migration on MySQL and Postgres.
  • Decision record added.
  • Impact map complete (plan_local_java_tests.py --check-branch).

🤖 Generated with Claude Code

@Vamsi-klu
Vamsi-klu marked this pull request as ready for review November 27, 2026 04:52
@Vamsi-klu
Vamsi-klu requested review from a team as code owners November 27, 2026 04:52
@github-actions

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.

Main made every lineage write one LineageWriteTransaction that takes its
guard-row locks first. The dashboard chart batch write now runs through it and
locks the edge before it locks or reads the dashboard and chart; its search,
cache and RDF projections still run after commit.
@Vamsi-klu

Copy link
Copy Markdown
Contributor Author

Merged main into this branch (a24e251). Main now runs every lineage write as one LineageWriteTransaction that takes its guard locks first (ADR:2026-11-26-domain-lineage-rollup-writers-lock-guard-rows-in-one-order), so I moved the dashboard chart batch write onto it. It now locks the edge before it locks or reads the dashboard and chart, and the search, cache and RDF updates still run after commit.

Ran locally on a24e251, MySQL + Elasticsearch:

  • LineageResourceIT#dashboardChartBatch*: 7 run, 0 failures, including dashboardChartBatchConcurrentWritersCreateOneEdgeAndOneEvent
  • LineageRepositoryTest, LineageChildrenNamesTest, ElasticSearchEntityManagerUpdateByQueryRetryTest, OpenSearchEntityManagerUpdateByQueryRetryTest: 78 run, 0 failures

@sonika-shah sonika-shah added the safe to test Add this label to run secure Github workflows on PRs label Dec 1, 2026
@yan-3005

yan-3005 commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Hi @Vamsi-klu, thanks for the work on this. We discussed it with the backend team. We'd like to change the approach before reviewing further.

The server already stores which charts belong to a dashboard, as the Dashboard HAS Chart relationship. The ingestion stage from #34985 only draws edges for those same charts. So the server should create the Dashboard to Chart lineage edge itself, from that relationship. We don't want a new API for this.

Could you rework the PR this way?

  1. Take special care with overrideLineage. When it is on, ingestion deletes every DashboardLineage edge into a chart and only writes back the edges it draws itself. If the server's edge uses the same source, an override run deletes it and nothing recreates it. The server's edge must survive an override run. Giving it its own lineage source is one way.
  2. When a chart is added to a dashboard, its edge is created. When a chart is removed, its edge is removed. This should hold for create, bulk create and update.
  3. Follow the lineage write rules in ADR:2026-11-26-domain-lineage-rollup-writers-lock-guard-rows-in-one-order.
  4. Add a migration so existing dashboards get the edge, and edges already written by the 2.1 ingestion stage are not lost on the next override run.
  5. Remove the ingestion stage, the batch API, the /capability route and the new schemas.
  6. Add ITs for create, chart added, chart removed, bulk create, and an overrideLineage run that keeps the edge.

This also gives the edge to dashboards created through the API, which today never get it.

Testing. Please test it end to end and share the evidence in the PR description:

  • List every test scenario you ran, with the result for each.
  • Run a real dashboard ingestion against the patched server, with overrideLineage off and on, and a rerun of each. Share the run summary and the request counts compared with the current behavior.
  • Create and update dashboards through the API, including adding and removing charts.
  • Upgrade a 2.1 instance that already has these edges and confirm the migration result.
  • Run on MySQL and PostgreSQL, with Elasticsearch and OpenSearch.
  • Share screenshots of the lineage view showing the Dashboard to Chart edges after ingestion, after an override run, and after a chart is removed.
  • Share the IT and unit test results with the test counts.

The 2.1 ingestion stage read every dashboard back and wrote one lineage
request per chart, which slowed dashboard ingestion (open-metadata#38698). The server
already holds the same set as the Dashboard HAS Chart relationship.

- DashboardRepository reconciles a dashboard's chart edges after its
  create, bulk create or chart change commits, through LineageRepository.
- The edges carry a new DashboardChartLineage source, so an
  overrideLineage run no longer deletes them.
- The 2.1.2 migration adds the missing edges and moves the edges the 2.1
  stage drew to the new source.
- Ingestion drops the yield_dashboard_chart_lineage stage.
- Replaces the batch lineage endpoint proposed earlier in this PR.

ADR:2026-12-04-the-server-owns-dashboard-to-chart-lineage
@yan-3005
yan-3005 requested a review from a team as a code owner December 4, 2026 08:25
@yan-3005
yan-3005 requested review from anuj-kumary and removed request for a team December 4, 2026 08:25
@yan-3005 yan-3005 added the To release Will cherry-pick this PR into the release branch label Dec 4, 2026
yan-3005 and others added 2 commits December 4, 2026 14:18
The sync runs as a post-commit action that only logs, so any failure
escaping it dropped the edges of every dashboard left in a bulk write.
Each dashboard and each edge write now catches and logs its own failure.
A stored dashboard to chart row without details is treated as another
writer's edge instead of throwing.
@yan-3005 yan-3005 added To release Will cherry-pick this PR into the release branch and removed To release Will cherry-pick this PR into the release branch labels Dec 4, 2026
# Conflicts:
#	ingestion/src/metadata/ingestion/source/dashboard/dashboard_service.py
#	ingestion/tests/unit/topology/dashboard/test_dashboard_chart_lineage.py
The browser tests run with isolate:false, so the core toast queue is
shared across files in a worker. Data contract suites earlier in the
shard left "Data contract saved successfully" toasts over the bulk
removal Delete button, and two output-port tests timed out clicking it.
Each data product ports suite now runs the shared closeToasts helper
before every test.
@gitar-bot

gitar-bot Bot commented Dec 4, 2026

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

The 2.1.2 backfill and post-commit reconciliation alter stored dashboard-chart lineage edges, so failures could leave lineage relationships incomplete or stale.

Moves Dashboard to Chart lineage from ingestion to the server, with a new DashboardChartLineage source reconciled on dashboard create, bulk create, and chart changes, plus a 2.1.2 backfill migration. Resolved this session: a server-rejected dashboard is no longer counted as failed twice, lineage projection no longer holds a row lock across search/RDF I/O, and one dashboard's non-JDBI failure no longer skips chart lineage for the rest of a bulk. No open issues remain.

✅ 3 closed
✅ Edge Case: A dashboard the server rejected is counted as failed a second time

📄 ingestion/src/metadata/ingestion/sink/metadata_rest.py:611-622 📄 ingestion/src/metadata/ingestion/sink/metadata_rest.py:634-637
_read_dashboard_for_chart_lineage calls get_by_name(..., nullable=False), and OpenMetadata._get raises on a 404 when nullable is False. Here is how a rejected dashboard gets counted twice. The source sets context.dashboard from the create request it built. If the bulk PUT then rejects that dashboard, _flush_buffer records it in status.failed. The source has already queued an OMetaDashboardChartLineageRequest for that name, so the drain reads a dashboard that does not exist, gets a 404, and records a second failure ("Could not read dashboard chart membership"). The old path used the default nullable=True and skipped a missing dashboard without logging anything. With this change the failure counts are inflated and every rejected dashboard shows up twice in the report. To fix it, keep nullable=True and skip a None result, as the legacy flow did. Errors that are not 404s (403, 5xx) would still be reported.

✅ Bug: Committed-lineage projection holds a row lock across search/RDF I/O

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/LineageRepository.java:438-452 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/LineageRepository.java:422-431
projectCommittedLineage(from, to) opens a new dao.useTransaction, takes SELECT … FOR UPDATE on the edge row through lockRelationshipDetails, and keeps that lock while it makes the synchronous searchClient.updateLineageChecked call, the cache invalidation, and addLineageToRdf (lines 441-451, 462-471). This runs for the dashboard→chart edge and also for every service, domain and data-product rollup edge that buildExtendedLineage writes through write.project() (line 431).

The Accepted record ADR:2026-11-26-domain-lineage-rollup-writers-lock-guard-rows-in-one-order says: "No search or cache I/O in the locked transaction… A rollup's search write reads the row as stored when it runs… writes it synchronously, then reads the row again and writes again while it differs (at most three writes)." This path breaks that rule in two ways:

  • Contention: any lineage writer that upserts the same domain or service rollup row has to wait on this row lock for as long as Elasticsearch/OpenSearch and RDF take to respond. That writer may already hold its edge and pair guard stripes, so every write on those stripes stalls behind the search call. A slow or unreachable search cluster turns into DB lock waits and lock timeouts, which surface as WRITE_FAILED to the batch.
  • Convergence: it replaces the record's read/write/re-read rollup sync with a single locked write.

Fix: read the stored JSON without a lock (or in a short transaction that commits right away), then do the search write and RDF update outside any transaction, and re-read until the stored JSON matches, as the ADR describes. If the lock-based design is intended instead, add a record that supersedes that rule.

✅ Bug: One dashboard's non-JDBI failure skips chart lineage for the rest of a bulk

📄 openmetadata-service/src/main/java/org/openmetadata/service/lineage/DashboardChartLineageSync.java:59-71 📄 openmetadata-service/src/main/java/org/openmetadata/service/lineage/DashboardChartLineageSync.java:97-105 📄 openmetadata-service/src/main/java/org/openmetadata/service/lineage/DashboardChartLineageSync.java:113-121 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DashboardRepository.java:445-452
The comment on syncDashboard says one dashboard's failure must not skip the rest of a bulk write, but the method only catches JdbiException. Any other RuntimeException gets out of dashboards.forEach(this::syncDashboard). Examples are a validation or authorization error from lineageRepository.addLineage or deleteLineage, a search or RDF projection error, or an NPE in chartEdgeSources when an UPSTREAM row has null JSON (JsonUtils.readValue(null, …) returns null and .getSource() then throws). PostCommitActionQueue.runGuarded only logs the exception, so every dashboard left in that bulk chunk silently gets no edges. The ADR says a missing edge then stays missing until that dashboard's charts change again, and an ingestion re-run with unchanged charts never repairs it. The fix is to catch RuntimeException per dashboard (and per chart edge), log it, and treat a missing or unreadable edge JSON as a foreign edge instead of dereferencing it.

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

@yan-3005 yan-3005 changed the title Fixes 38698: Batch dashboard chart lineage writes Fixes #38698: Draw Dashboard to Chart lineage on the server instead of in ingestion Dec 4, 2026
@yan-3005
yan-3005 merged commit 6866b01 into open-metadata:main Dec 4, 2026
29 of 32 checks passed
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.1 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.0 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@gh-bot-collate

gh-bot-collate Bot commented Dec 4, 2026

Copy link
Copy Markdown

🤖 Backport to 2.1 failed. The conflict could not be resolved, so this change is not on that branch. Resolver run.

@gh-bot-collate

gh-bot-collate Bot commented Dec 4, 2026

Copy link
Copy Markdown

🤖 Backport to 2.0 failed. The conflict could not be resolved, so this change is not on that branch. Resolver run.

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

Labels

safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2.1: Dashboard → Chart lineage stage flushes the sink and makes blocking calls per dashboard, more than doubling Looker ingestion time

4 participants