Skip to content

Concurrent assets/add and DELETE of a Data Product orphans its entity_relationship row (unreachable, un-deletable "ghost") #33741

Closed

Description

@jamiejackson

Affected module

Backend

Describe the bug

When an assets/add for a Data Product races the DELETE of that same Data Product, a row describing the product's relationship to the asset can survive in entity_relationship with no backing entity at the fromId end -- the delete tears the entity down while the concurrent add writes the edge just after. The dangling row is:

  • not returned by GET /api/v1/dataProducts/{id} (404),
  • not returned even with ?include=deleted (404 -- so the entity is genuinely gone, not soft-deleted),
  • not listable or deletable through any API surface we could find,
  • yet still resolvable enough that any PUT /api/v1/dataProducts/{fqn}/assets/add involving the linked asset fails with an opaque not_found naming the deleted product's UUID.

We call these "ghost" data products. Because the only way to observe one is to have a bulk asset-add fail against it, they accumulate silently, and the only remediation we have found is a direct DELETE FROM entity_relationship against the database.

Concrete instance (OM 1.12.8, Postgres):

  • Ghost data product UUID ca3fc4f7-23e7-467e-9456-04bdba4af9a5.
  • GET /api/v1/dataProducts/ca3fc4f7-.../ -> 404 {"code":404,"message":"HTTP 404 Not Found"}.
  • GET /api/v1/dataProducts/ca3fc4f7-.../?include=deleted -> 404 (entity fully gone, not deleted=true).
  • The relationship poisoned assets/add 280 times before we built tooling to identify it.
  • Adding the linked asset makes OM resolve the relationship, find no entity at fromId, and return not_found for the ghost UUID. No get/list/delete API surface exposes the edge.

Impact: a single ghost poisons every asset linked to its dangling edge; the bulk add returns those assets as rejected with a not_found for a UUID the caller cannot resolve, list, or delete. There is no API-driven detection or remediation, and the error gives no signal that it is an orphaned relationship rather than a transient failure.

Repro lab & repro case: https://gist.github.com/jamiejackson/83102f25a66e882ec97b1b18b1c6e142

Related cleanup feature request: #33742

To Reproduce

The orphan is born from a race between assets/add and DELETE of the same Data Product, not from any particular delete mode. We reproduced it deterministically in a single-node Docker lab (prebuilt images, Postgres backend): concurrent add + delete orphaned the asset edge on 8/8 iterations. A plain soft delete in isolation, and hardDelete=true&recursive=true in isolation, were both clean -- so the trigger is the overlap, not the flag.

Setup notes for 1.12.x (so the steps actually run):

  • CreateDataProduct takes domains: [<name>] (plural array), not domain.
  • An asset only attaches if it already shares the Data Product's domain (a "Data Product Domain Validation" rule rejects the add otherwise), so set the asset's domain first.

Steps:

  1. Create a domain, a database service/database/schema, and one table in that domain.
  2. Create a Data Product in the same domain.
  3. Fire PUT /api/v1/dataProducts/{fqn}/assets/add (adding the table) and DELETE /api/v1/dataProducts/{id} concurrently (a soft delete is enough).
  4. Repeat a handful of times.
  5. Observe an orphan: a row in entity_relationship with fromEntity='dataProduct' for which data_product_entity has no row. That id then 404s on GET, on GET ?include=deleted, on GET ?include=all, and on DELETE ?hardDelete=true -- yet any later assets/add touching the linked asset fails with an opaque not_found naming that id.

This matches our production trigger: a client that fans assets/add out over parallel workers while a create-rollback DELETE can land in the same window (which is exactly what our bulk-add client does).

Expected behavior

No relationship row should outlive the entity on either end. Deleting a Data Product must not leave an entity_relationship row behind, and a concurrent assets/add must not be able to write an edge for a Data Product that is being (or has been) deleted -- the delete and the add need to be serialized or the add rejected, so no edge lands after the entity is gone. Failing that, asset-add resolution should skip a relationship whose entity no longer resolves instead of returning an opaque not_found, and a bulk add should never be blockable by a reference the API itself cannot resolve.

OS

Docker

Python version

No response

OpenMetadata version

1.12.8, 1.12.14

OpenMetadata Ingestion package version

No response

Additional context

Backend is Postgres. Note hardDelete=true&recursive=true does not prevent this -- in the lab it is clean only absent the race; a concurrent add still orphans the edge. So a "always hard-delete" client contract is not the fix; the fix is on the concurrency/ordering path (or reaping edges whose entity is gone). Operability follow-up filed separately (link the enhancement issue here once opened).

Pre-submission checklist

  • I searched for duplicate issues.
  • I removed credentials, hostnames, emails, and other sensitive data from logs and config.

Activity

  1. added
    bug
    on Sep 21, 2026
  2. zhang-arvin commented on Sep 22, 2026

    @zhang-arvin
    Contributor

    Hi @zhang-arvin here — I'd like to work on this.

    The dangling entity_relationship row is the classic delete-vs-add race: the DELETE tears the entity down while the concurrent assets/add writes the edge just after, with no FK/liveness check on fromId. Plan: re-validate the fromId entity under the same lock/transaction as the edge write (and drop the edge instead of persisting it when the entity is gone), plus a cleanup path so already-orphaned rows become reachable or removable rather than poisoning assets/add with an opaque not_found.

    Please assign this to me if that's convenient.

  3. jamiejackson commented on Oct 5, 2026

    @jamiejackson
    Author

    @zhang-arvin , could you give a lay explanation of the status of the fix, please? (Either here or in the fix thread.)

    The existing responses in the fix thread are confusing since they deal with peculiarities of the pipeline that I'm not familiar with.

  4. added a commit that references this issue on Oct 8, 2026
    80873af
  5. added 2 commits that reference this issue on Oct 21, 2026
  6. moved this to In Progress 🏗️ in Shippingon Oct 22, 2026
  7. moved this from In Progress 🏗️ to Done ✅ in Shippingon Nov 4, 2026
  8. added a commit that references this issue on Nov 4, 2026
    0055904
  9. added a commit that references this issue on Nov 5, 2026
    044f91b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    • Status
      Done ✅
    • Status
      Done ✅

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions