ATLAS-4988: BusinessMetadata with attribute of data type Array takes time to Delete.#490
ATLAS-4988: BusinessMetadata with attribute of data type Array takes time to Delete.#490UmeshPatil-1 wants to merge 2 commits intoapache:masterfrom
Conversation
...rc/main/java/org/apache/atlas/repository/store/graph/v2/AtlasBusinessMetadataDefStoreV2.java
Show resolved
Hide resolved
...rc/main/java/org/apache/atlas/repository/store/graph/v2/AtlasBusinessMetadataDefStoreV2.java
Outdated
Show resolved
Hide resolved
|
|
||
| return CollectionUtils.isNotEmpty(atlasSearchResult.getEntities()); | ||
| Iterable<AtlasVertex> vertices = graph.query() | ||
| .has(Constants.ENTITY_TYPE_PROPERTY_KEY, typeName) |
There was a problem hiding this comment.
Is it necessary to add ENTITY_TYPE_PROPERTY_KEY filter here? If yes, note that all subTypes of types inapplicableTypes should be checked as well; consider a business attribute associated with a type like DataSet.
| Iterable<AtlasVertex> vertices = graph.query() | ||
| .has(Constants.ENTITY_TYPE_PROPERTY_KEY, typeName) | ||
| .has(vertexPropertyName, AtlasGraphQuery.ComparisionOperator.NOT_EQUAL, (Object) null) | ||
| .has(Constants.STATE_PROPERTY_KEY, AtlasEntity.Status.ACTIVE.name()) |
There was a problem hiding this comment.
Is it necessary to check only for ACTIVE entities? The business metadata can't be deleted even when a deleted entity has reference to it, right?
...rc/main/java/org/apache/atlas/repository/store/graph/v2/AtlasBusinessMetadataDefStoreV2.java
Outdated
Show resolved
Hide resolved
0d5f0b8 to
f684d10
Compare
repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasDefStore.java
Show resolved
Hide resolved
| if (existingDef != null && !forceDelete) { | ||
| boolean hasIndexableAttribute = hasIndexableAttribute(existingDef); | ||
|
|
||
| if (!hasIndexableAttribute) { |
There was a problem hiding this comment.
The hasIndexableAttribute check could be expensive if there are many attributes.
Consider caching this in the BusinessMetadataDef or TypeRegistry.
|
|
||
| LOG.debug("<== AtlasBusinessMetadataDefStoreV2.preDeleteByName({}): {}", name, ret); | ||
| if (!hasIndexableAttribute) { |
There was a problem hiding this comment.
The hasIndexableAttribute check could be expensive if there are many attributes.
Consider caching this in the BusinessMetadataDef or TypeRegistry.
| return false; | ||
| } | ||
|
|
||
| private Set<String> getApplicableTypesWithSubTypes(Set<String> applicableTypes) throws AtlasBaseException { |
There was a problem hiding this comment.
Suggestions:
-
Add JavaDoc explaining WHY sub-types are needed as this is an important business logic - without JavaDoc, developers won't understand the inheritance scenario.
-
Consider caching the result in TypeRegistry to avoid repeated calculations
...rc/main/java/org/apache/atlas/repository/store/graph/v2/AtlasBusinessMetadataDefStoreV2.java
Outdated
Show resolved
Hide resolved
repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/apache/atlas/repository/store/graph/v2/AtlasBusinessMetadataDefStoreV2.java
Outdated
Show resolved
Hide resolved
…e handling, enhance logging, and fix indexability gate. Added debug logs for force-flag behavior, clarified error messages, and improved query efficiency. Centralized validation logic and distinguished infrastructure errors. Added test coverage for mixed indexable/non-indexable BM deletion.
ATLAS-4988
What changes were proposed in this pull request?
Background: In Apache Atlas, deleting a Business Metadata (BM) definition requires a pre-check to ensure no existing entities are assigned to those attributes. For attributes with a data type of Array (multi-valued), the deletion process was taking an exceptionally long time (e.g., over 55 minutes for -1,18,300 entities), even when the BM was not assigned to any entity.
Root Cause:
ARRAY BM attributes are not indexed in Solr.
Solr therefore performs a full collection scan when queried with NOT_EMPTY, causing severe latency.
The previous logic forced all BM attributes (STRING + ARRAY) through Solr.
This was efficient for STRING attributes but pathological for ARRAY attributes.
The earlier implementation excluded deleted entities.
This allowed historical BM references to be missed, leading to potential integrity violations.
The Solr query requested attribute payloads, increasing I/O cost even though only existence was required.
Changes Proposed:
Impact:
Performance Gain: Deletion time for Business Metadata with Array attributes reduced from -55 minutes to -25 second's.
Reliability: Maintains strict data integrity by ensuring no "in-use" Business Metadata can be deleted.
Scalability: The fix ensures that as the number of entities grows, the deletion of metadata remains performant.
Correctness:Prevents deletion when BM is referenced by: Active entities, Deleted (historical) entities, Subtypes via inheritance and Custom entity types.
How was this patch tested?
Maven Build:
Build Successful.
Manual Testing:
The Patch was tested on cluster:- Result's as per below
1. Time taken to delete unassigned BM of String type :- Existing Code :- 2 sec - 4 sec, Updated Code:- 2 sec - 3 Sec.
2. Time taken to delete unassigned BM of Array type :- Existing Code :- 1 Hr 40 min, Updated Code:- 1.5 min - 3 min.
Please refer the attached sheet on JIRA-4988 ticket for more insight's