Repository navigation
Fixes #30679: detach conflicting data products on data product domain change - #32944
Conversation
… change Moving a data product's domain re-homes its assets to the new domain but left any other data product still assigned to those assets (or to descendants that inherit their domain) whose domain no longer matched. Those assets then failed the "Data Product Domain Validation" rule on every subsequent edit, and a reindex could not recover the persisted mismatch. After the asset domain migration, detach the now-conflicting data-product assignments from the direct assets and from inherited-domain descendants, mirroring the Domain page cleanup. Gated on the validation rule being enabled; when the rule is disabled the mismatch is a legal configuration and is left untouched. Detach uses the rule's exact disjoint-domain semantics, so matching assignments (including the moved data product itself) are preserved.
❌ 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 |
- Detach every data product from an asset left with no domains: the validation rule fails any asset that has data products but no domains, so clearing a data product's domains must also drop the assignments. conflictsWithDomains now treats an empty effective-domain set as a conflict, mirroring validateDataProductDomainMatch. Covered by a new IT. - Reconcile inherited-domain descendants against the parent asset's own effective domains rather than the moved data product's new domains, so a descendant's valid assignment to one of the asset's other domains is not wrongly detached when multiple domains per asset are allowed.
Replace the per-node recursive walk with a level-by-level BFS that batches its reads (findToBatchAllTypes / findFromBatch), and collect detached assets for a single batched reindex (updateEntitiesByReference) instead of one search write per asset. Behaviour is unchanged: same disjoint-domain detach semantics, same soft-deleted skipping, same rule gate. The query cost drops from O(nodes in the asset subtree) to O(tree depth), so a data product assigned to a schema/database/service no longer fans out to tens of thousands of queries inside the domain-change transaction.
…ciliation Two regressions from the previous batching commit, both invisible to the IT suite (it runs with caching off and does not assert search state): - Descendant refs were built from relationship rows and carried no FQN, so invalidateCacheForEntity skipped the by-name cache eviction (guarded by fqn != null) and a detached asset stayed cached with its stale data-product until TTL. Resolve the detached assets through EntityUtil.populateEntityReferences (batched per type, FQN filled in place) before detaching. - The batched reindex ran un-deferred inside the domain-change @transaction, so updateEntitiesByReference re-read uncommitted rows. Wrap it in deferIfFlushScopeActive so it runs post-commit against committed state, per that method's documented contract. Also add a visited-set guard to the descendant BFS so it terminates on a containment cycle or a node reached via multiple parents.
The batched BFS still loaded an entire tree level at once (findToBatchAllTypes + batchFetchDomainIds accumulate every row), so peak heap was O(widest level) — a data product on a database/service with hundreds of thousands of tables could OOM on that single load. Reduce each level's children to lightweight (id, type) refs immediately and do the heap-heavy work (own-domain lookup, data-product lookup, detach + reference hydration) in bounded chunks of DESCENDANT_RECONCILE_CHUNK_SIZE, mirroring bulkHardDeleteSubtree's per-level chunking. Peak heap is now ~O(chunk * tree-depth) of hydrated state plus the level's lightweight id refs, instead of the whole level hydrated at once.
Code Review ✅ No issues found 4 closed / 4 findings🟡 Medium risk Detaches conflicting data product assignments when a data product's domain changes, preventing migrated assets and inherited-domain descendants from violating the Data Product Domain Validation rule. Soft-deleted assets are now properly skipped, recursive queries have been batched by traversal level to bound memory use, descendants are reconciled against the correct domain set, and descendant cache invalidation has been corrected. Added integration tests covering direct conflicts, inherited descendants, and soft-deleted assets. ✅ 4 closed✅ Edge Case: Soft-deleted asset/child aborts the domain change
✅ Performance: Recursive per-node DB queries over full asset subtree in txn
✅ Bug: Descendants reconciled against wrong domain set
✅ Bug: Descendant refs lack FQN, by-name cache not invalidated
OptionsDisplay: compact → Counting what did not apply, without listing it. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Closes #30679
Describe your changes
Changing a Data Product's domain re-homes its assets to the new domain, but left behind any other data product still assigned to those assets whose domain no longer matched. The affected assets then failed the default Data Product Domain Validation rule on every subsequent edit (
400 RULE_VIOLATION), and a reindex could not recover the state because the mismatch is persisted, not an indexing artifact. The Data Product domain change was the only route that let this through — the Domain page move, changing an asset's own domain, and cross-domain assignment are all already handled or rejected.After the existing asset-domain migration in
DataProductRepository.updateDataProductDomains, this detaches the now-conflicting data-product assignments, mirroring the Domain pagecleanupDataProductsbehaviour:The detach reuses the validation rule's exact disjoint-domain semantics, so matching assignments — including the moved data product itself — are preserved and nothing is over-detached. A data product with no domains never conflicts.
The whole step is gated on the Data Product Domain Validation rule being enabled. When the rule is disabled the mismatch is a legal configuration and assignments are left untouched, matching pre-existing behaviour.
Deferred to a fast-follow (kept out to keep this diff focused): enriching the rule-violation message to name the offending data product and domain. That requires threading specifics out of the boolean JsonLogic operation in the shared rule engine — a different, cross-cutting concern. With this fix these domain-change flows no longer trigger the violation in the first place.
Type of change
Tests
Added two integration tests in
DataProductResourceIT, both verified RED without the fix and GREEN with it (full class green, no regressions):test_domainChangeDetachesConflictingDataProducts— a schema inFinanceassigned to two data products (both inFinance); moving one toHRdetaches the one left behind, keeps the moved one, and the schema stays editable.test_domainChangeDetachesConflictingDataProductsOnInheritedDescendants— a child table inheriting its schema's domain and assigned to a data product that stays inFinance; moving the schema's data product toHRdetaches the child's conflicting assignment and the child stays editable.The rule-disabled branch is not covered by an integration test because the IT harness cannot toggle the global rule at runtime (see the pre-existing
@Disabledtests notingEntityRulesUtil.toggleRule not working via API); the gate is exercised via the enabled default path.The PR appears safe to merge; the previously reported correctness issues are fixed and no new actionable failures remain.
Summary
The PR reconciles data-product assignments after a data product’s domains change, removing assignments that conflict with migrated or inherited asset domains.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Data product domains change] --> B[Migrate direct asset domains] B --> C{Domain validation rule enabled?} C -- No --> Z[Leave assignments unchanged] C -- Yes --> D[Reconcile direct assets] D --> E[Walk containment levels] E --> F{Child has explicit domain?} F -- Yes --> G[Prune child subtree] F -- No --> H[Use inherited parent domains] H --> I{Assignment conflicts?} I -- No --> E I -- Yes --> J[Remove relationship and lineage] J --> K[Invalidate asset cache] K --> L[Queue asset for reindex] L --> E E --> M[Defer batched reindex until commit]Reviews (8) · Last reviewed commit: "perf: bound descendant reconciliation me..."