Repository navigation
[2.0] Fixes open-metadata/openmetadata-collate#8646: a hard delete keeps the tags of entities that share its FQN (#38126) - #38230
Conversation
…eps the tags of entities that share its FQN (#38126) Backport of #38126. tag_usage and field_relationship key their rows by FQN hash alone, so a hard delete removed the rows of every entity at or under the deleted entity's FQN, whatever its type. Hard-deleting a pipeline service named like a database service removed the tags and tiers of every table in it. Differences from main: - The new TagUsageDAO and FieldRelationshipDAO statements live in CollectionDAO, where 2.0 keeps those DAOs. - 2.0 has no ChildFieldResolver registry, so hasTaggedFields() defaults to false and the ten repositories that override taggedFieldContainers() return true. - cleanup() runs both FQN-prefix deletes after entity_extension, the order 2.0's bulk cascade already uses. - No MetricGroup opt-in or impact-map entry; neither exists on 2.0. (cherry picked from commit ad4d5f2)
❌ 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 🔴 High riskChanging hard-delete cleanup to probe shared FQNs and filter tag and relationship rows affects stored-data integrity; mistakes could erase metadata for surviving entities. Backport of the hard-delete fix so that deleting an entity no longer removes tags and tiers belonging to other entities that share its FQN, such as a pipeline service named like a database service. Hard deletes now check entity type before removing 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 |
| private Map<String, OwnedRows> ownedRows(List<String> fqns) { | ||
| Map<String, String> hashes = new LinkedHashMap<>(); | ||
| fqns.forEach(fqn -> hashes.put(fqn, FullyQualifiedName.buildHash(fqn))); | ||
| Map<String, OwnedRows> owned = new LinkedHashMap<>(); | ||
| if (taggable) { | ||
| List<String> hashList = List.copyOf(hashes.values()); | ||
| Set<String> kept = keptHashes(hashList); |
There was a problem hiding this comment.
New Java skips required conventions. The Java guide requires
final on parameters and local variables that are not reassigned, getFirst() instead of get(0), and constants for repeated strings. The new declarations here omit final. The added tests also use get(0), and nestedHolderHashes() repeats "under". Apply these conventions across the added Java code before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Describe your changes:
Fixes open-metadata/openmetadata-collate#8646
Backport of #38126 to 2.0. The bug was reported on 2.0.8 and is the same on this branch.
tag_usageandfield_relationshipkey their rows by FQN hash alone, and an FQN is unique only within a type. Before this change, 2.0's hard delete removed every row at and under the deleted entity's FQN, whatever entity those rows belonged to. Hard-deleting a pipeline service named like a database service removed the tags and tiers of every table in the database service. 2.0 already has the change this builds on:HardDeleteCleanupITand ADR:2026-11-03-a-hard-delete-removes-only-rows-of-the-deleted-entity came with #37162.What changed (same as #38126):
FqnKeyedRowCleanupruns the FQN-prefix deletes for both the single-entity cleanup and the bulk cascade. First it looks for entities the delete leaves in place:CASCADE_ROOT_FQN_SHARED).nestsUnderUnrelatedFqns()). Data models name the dashboard service as their FQN parent (fqnParentType()).deleteTagLabelsByTargetPrefixOutside,deleteAllByPrefixOutsideand the probe querylistEntityFqnHashes.Differences from #38126:
TagUsageDAOandFieldRelationshipDAOnested inCollectionDAO; theClassificationTagDAOs/CoreRelationshipDAOssplit is main-only. The three new statements live there, with the same SQL.ChildFieldResolverregistry. Each repository whose entities have tagged inline fields overridestaggedFieldContainers()instead. SohasTaggedFields()defaults tofalse, and those ten repositories returntrue: tables, topics, data models, containers, search indexes, ML models, pipelines, API endpoints, worksheets and Drive files. These are the same types main covers through its registry plusFileRepository.cleanup(). 2.0'scleanup()deletedfield_relationshipbeforeentity_extension, andtag_usageafter it. Both deletes now run in one call afterentity_extension. That is main's order, and the order 2.0's bulk cascade already used, so a direct delete and a cascade delete over the same rows take the tables in the same order.Entity.getEntityRepositories()returns 2.0's non-genericEntityRepository<? extends EntityInterface>.MetricGroupRepositoryopt-in, since metric groups don't exist on 2.0;impact-map.jsonentry, since 2.0 has no impact map;IN_HARD_DELETE_CASCADEflag, main's restructureddelete()andcleanup(), andContextFileRepositorymethods 2.0 doesn't have.FqnKeyedRowCleanup, the new ADR andHardDeleteCleanupITare line-for-line the same as onmain, except that an IT comment which namedChildFieldResolveris reworded.FqnKeyedRowCleanupTestdiffers only in namingCollectionDAOas the DAOs' host.Type of change:
High-level design:
Same as #38126, which covers the alternatives considered and the cost: two more queries per hard delete, and two more before a recursive delete's cascade. No migration and no API change. Rows a past delete already removed are not restored.
Tests:
Use cases covered
Same as #38126:
model, or of a glossary keeps the tags of the table, of the service's data models, and of a metric named like one of the glossary's terms.service.db).Unit tests
FqnKeyedRowCleanupTestfrom Fixes open-metadata/openmetadata-collate#8646: a hard delete keeps the tags of entities that share its FQN #38126. It namesCollectionDAOas the DAOs' host and is otherwise unchanged.mvn -B package -pl :openmetadata-service -am -Dtest=…on this branch: 44 tests, 0 failures.FqnKeyedRowCleanupTest: 14EntityRepositoryRestoreTest: 17EntityDAOTest: 11MetricRepositoryTest: 1DaoStatementGuardTest: 1, covering the three new DAO statements.Backend integration tests
HardDeleteCleanupITfrom Fixes open-metadata/openmetadata-collate#8646: a hard delete keeps the tags of entities that share its FQN #38126 (8 new tests, 11 in total).mvn -B verify -pl :openmetadata-integration-tests -am -Pmysql-elasticsearch -DintegrationTests.lane=parallel -Dit.test=HardDeleteCleanupIT …): 11 tests, 0 failures. The merge queue runs the other engines.Ingestion integration tests
Playwright (UI) tests
Manual testing performed
Compared 2.0's
cleanup(), its bulk cascade and the two DAO statements withmain's code before #38126. They delete by FQN prefix with no type check, asmaindid, so the bug and the fix both apply. #38126 has before/after recordings of the reported scenario in the UI.UI screen recording / screenshots:
Not applicable — backend-only fix.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.🤖 Generated with Claude Code
The Java convention requirement must be satisfied before merging.
Findings
Summary
This backport protects surviving entities' tags and field relationships when a hard delete reaches a shared fully qualified name.
mohityadav766 documents that shared rows may remain and defers collisions between parent-built names and inline fields until rows record entity types. The added Java code still needs the required convention cleanup noted below.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Hard delete] --> B[Find surviving entities sharing the name] B --> C{Which rows are shared?} C -->|Same name or inline field| D[Keep shared rows] C -->|Nested surviving entities| E[Delete outside surviving subtrees] C -->|None| F[Delete the full prefix] A --> G{Recursive root keeps descendant rows?} G -->|Yes| H[Each descendant cleans its own rows] G -->|No| I[Covered descendants rely on root cleanup]Reviews (1) · Last reviewed commit: "[2.0] Fixes open-metadata/openmetadata-c..." · Reviewed by Greptile