Skip to content

fix(zdu): keep an entity on hard rollback when a newer version's row belongs to another run - #21572

Open
gdatahub wants to merge 2 commits into
masterfrom
zdu/hard-rollback-keeps-newer-rows
Open

gdatahub wants to merge 2 commits into
masterfrom
zdu/hard-rollback-keeps-newer-rows

Conversation

@gdatahub

@gdatahub gdatahub commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Follows #20280. After a zero-downtime upgrade rollback, a hard rollback of an ingestion run keeps the entity the run created when a newer version's row on it belongs to another run, instead of deleting that row with the entity. Only applies with entity and aspect tolerance on, which is off by default.

What was wrong

Changes

  • AspectDao.getLatestRowsOfUrn (new): the latest row of every aspect stored for a urn, as stored, including aspects the registry doesn't know.
    • Ebean: raw SQL WHERE urn = :urn AND version = 0, through the routing seam like batchGet (table from tableResolver, database from resolveBatchGetDatabase with write intent, since the caller decides a delete from it).
    • Cassandra: a select within the urn's partition, filtered to version = 0.
  • EntityServiceImpl.ownedOnlyByRun: while entity and aspect tolerance is on, it also reads those rows for aspects the registry doesn't know. The entity is kept if any of them, other than status, belongs to someone other than the run. Those rows are read without a lock; the rows the registry knows are still locked, as before. The run's own aspects are still rolled back one by one, as for any kept entity.
  • docs/how/breaking-changes.md: an entry for the change.

Flags off

Gated on entity and aspect tolerance, so with it off nothing changes, including the MySQL behaviour that predates #20280. It only ever makes the rollback keep more, never delete more.

Testing

  • EntityServiceTest, run for Ebean (H2) and Cassandra (Testcontainers): another run's newer-version row keeps the entity and the row; the run's own newer-version row lets the entity be deleted, row included; with strict handling the entity is deleted as before. The "keeps" test fails without the fix.
  • EbeanAspectDaoSeamRoutingTest: the new read resolves the table and transaction scope from the caller's context, and returns every latest row of the urn (including an unknown aspect) and no older versions or other urns.
  • Results: EbeanEntityServiceTest 180, CassandraEntityServiceTest 82, CassandraAspectDaoTest 32, AspectDaoTest 13, EbeanAspectDaoSeamRoutingTest 5, EbeanAspectDaoTransactionRetryTest 6, EbeanTimelineServiceTest 3, CassandraTimelineServiceTest 3: all pass.
  • Live, local Docker quickstart (MySQL). The same probe was run against master and this branch, each with tolerance off and on. Run R1 ingests a dataset (creating it); run R2's row for an aspect only the newer version knows is inserted as that version writes it (SQL row plus system-metadata document). Then a dry run and a hard rollback of R1.
master, off branch, off master, on branch, on
Dry run of R1 entitiesDeleted: 0 same same same
Hard rollback of R1 entity deleted (entitiesDeleted: 1) same entity deleted entity kept (entitiesDeleted: 0)
Rows left none none none datasetKey and R2's row
Control: R2 wrote an aspect this version knows kept, R2's row stays same same same

With tolerance off, the branch matches master, including the MySQL behaviour that predates #20280. Cassandra is covered by the Testcontainers tests, not a live deployment.

Performance

With entity and aspect tolerance on: one extra read per hard rollback of a run-created entity, and only once every row the registry knows belongs to the run. On Cassandra the version = 0 filter needs ALLOW FILTERING, so it reads the urn's partition, older versions included.

Questions for reviewers

@github-actions github-actions Bot added docs Issues and Improvements to docs product PR or Issue related to the DataHub UI/UX labels Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Smart test selection

pytest smoke tests

Mode: shadow. The selection below is computed but not applied; this PR still runs the default matrix (p0).

  • Selection: smart: tests for the tagged features, plus always-run modules, this PR's changed tests, and the plumbing sample if the PR changes the pytest harness
  • Size: 125 of 846 tests in 1 batch, predicted longest batch ~3 min
  • Tags: change-type: docs; feature-dev: entity-versioning, system-metadata; feature-user: ingestion; technical-layer: ebean-mysql
  • Confidence: MEDIUM (8 changed files)
  • Classifier reasoning: Hard rollback of ingestion runs now checks rows of unknown aspects via a new AspectDao method across Ebean and Cassandra, which is system-metadata/run-id logic tied to ingestion, plus a docs entry for the breaking change.

Medium confidence: a wrong tag means tests are skipped, so check the tags above against what this PR touches.

Selected scopes (25 files or classes, 125 tests)
  • tests/e2e/assertions/dbt_test_results_test.py
  • tests/e2e/authorization/test_self_entity_auth.py
  • tests/e2e/cli/ingest_cmd/test_timeseries_rollback.py
  • tests/e2e/cli/migrate_cmd/test_migrate_instance2instance_smoke.py
  • tests/e2e/cli/migrate_cmd/test_migrate_scenarios_smoke.py
  • tests/e2e/entity_versioning/test_effective_latest_versioning.py::TestEffectiveLatestVersioning
  • tests/e2e/entity_versioning/test_glossary_term_new_version.py
  • tests/e2e/entity_versioning/test_glossary_versioning.py
  • tests/e2e/entity_versioning/test_versioning.py
  • tests/e2e/entity_versioning/test_versioning_ingest.py
  • tests/e2e/entity_versioning/test_versioning_timeline.py
  • tests/e2e/frontend/test_static_asset_encodings.py
  • tests/e2e/managed_ingestion/managed_ingestion_test.py
  • tests/e2e/mcp/mcp_test.py
  • tests/e2e/odcs/test_odcs_ingestion.py
  • tests/e2e/openapi/v1/test_tracking.py
  • tests/e2e/platform_resources/test_platform_resource.py
  • tests/e2e/read_only/test_ingestion_list.py
  • tests/e2e/read_only/test_services_up.py
  • tests/e2e/search/test_search_projection.py::TestSearchProjection
  • tests/e2e/status/test_lifecycle_state.py::TestLifecycleStageAPIs
  • tests/e2e/telemetry/telemetry_test.py
  • tests/e2e/test_e2e.py
  • tests/e2e/test_stateful_ingestion.py
  • tests/e2e/trace/test_api_trace.py

Add the run-all-tests:pytest label to run the full pytest suite on this PR.

Playwright E2E tests

This run: smart

  • Selection: smart: specs tagged entity-versioning, ingestion, system-metadata plus the tests the change affects
  • Size: 24 tests in 6 spec files, ~4 min predicted on 1 shard(s)
Specs selected because of this PR (6)
Spec Tests Why
ingestion-v3/odcs-source.spec.ts 2/2 tagged ingestion
ingestion-v3/run-history.spec.ts 6/6 tagged ingestion
ingestion-v3/secrets-tab.spec.ts 4/4 tagged ingestion
ingestion-v3/sources.spec.ts 7/7 tagged ingestion
mutations/manage-ingestion-secret-privilege.spec.ts 3/3 tagged ingestion
schema-blame/schema-blame.spec.ts 2/2 tagged entity-versioning

Add the run-all-tests:playwright label to run the full Playwright suite on this PR.

commit 9d0e626 · workflow run

@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.12195% with 2 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...om/linkedin/metadata/entity/EntityServiceImpl.java 85.71% 0 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@gdatahub
gdatahub marked this pull request as ready for review November 24, 2026 13:13
@cursor

cursor Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

PR Summary

Overview
Hard rollback of an ingestion run no longer deletes a run-created entity when a newer DataHub version left aspect rows this build’s registry cannot see and those rows were written by another run. Previously ownedOnlyByRun only inspected registry-known aspects, so dry runs could say an entity would be kept while the real rollback wiped the whole URN—including foreign newer-version rows.

This adds AspectDao.getLatestRowsOfUrn (Ebean + Cassandra) to return every latest stored aspect row as-is, including unknown aspect names. When entity/aspect tolerance is enabled, ownedOnlyByRun still locks and checks known aspects, then scans those extra rows and refuses deletion if any non-status row’s runId differs from the rollback target.

docs/how/breaking-changes.md documents the behavior change (only with tolerance on; default off). New unit and seam-routing tests cover keep vs delete vs strict-handling cases.

Reviewed by Cursor Bugbot for commit 9d0e626. Bugbot is set up for automated code reviews on this repo. Configure here.

…belongs to another run

A hard rollback deletes an entity the run created only while the run still
owns all of it. EntityServiceImpl.ownedOnlyByRun reads only the aspects this
version's registry knows, so after a rollback it missed an aspect only the
newer version knows, written under another run: the entity was deleted with
that row, although the dry run (built from the system-metadata index) said
it would be kept.

With entity and aspect tolerance on, ownedOnlyByRun now also reads the latest
row of every aspect stored for the urn (new AspectDao.getLatestRowsOfUrn;
Ebean through the routing seam, Cassandra within the urn's partition) and
keeps the entity if one of the unknown aspects other than status belongs to
someone else. With tolerance off nothing changes.

This branch was successfully deployed

1 active deployment
Preview — 9d0e626e Deployed Nov 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Issues and Improvements to docs product PR or Issue related to the DataHub UI/UX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant