-
Notifications
You must be signed in to change notification settings - Fork 901
ATLAS-4988: BusinessMetadata with attribute of data type Array takes time to Delete. #490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…ay-type attributes.
| String qualifiedName = AtlasStructType.AtlasAttribute.getQualifiedAttributeName(businessMetadataDef, attributeDef.getName()); | ||
| String vertexPropertyName = AtlasStructType.AtlasAttribute.generateVertexPropertyName(businessMetadataDef, attributeDef, qualifiedName); | ||
| Set<String> applicableTypes = AtlasJson.fromJson(attributeDef.getOption(AtlasBusinessMetadataDef.ATTR_OPTION_APPLICABLE_ENTITY_TYPES), Set.class); | ||
| for (AtlasStructDef.AtlasAttributeDef attributeDef : businessMetadataDef.getAttributeDefs()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract the attribute iteration logic in checkBusinessMetadataRef to a private method (e.g., validateAttributeReferences) for better readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| return atlasSearchResult != null && CollectionUtils.isNotEmpty(atlasSearchResult.getEntities()); | ||
| } | ||
|
|
||
| private boolean isBusinessAttributePresentInGraph(String vertexPropertyName, Set<String> applicableTypes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Replace manual iteration with Graph Query for better performance:
The method isBusinessAttributePresentInGraph manually iterates over all vertices of each applicable type using graph.getVertices(Constants.ENTITY_TYPE_PROPERTY_KEY, typeName), then checks each vertex for the property and state. This can be slow for large graphs, as it loads and inspects every vertex in memory. This needs to be improved
2. Add error handling and logging:
No exception handling in the graph operations.
If the graph is unavailable or queries fail, it could lead to unhandled exceptions. Wrap the query in a try-catch and log warnings/errors.
Also, add optional performance logging to monitor query times in production.
3. Add JUnit tests for the new method covering:
-Non-indexable attributes with/without assignments.
-Inactive entities (should not count).
…handling and logging.
|
|
||
| return CollectionUtils.isNotEmpty(atlasSearchResult.getEntities()); | ||
| Iterable<AtlasVertex> vertices = graph.query() | ||
| .has(Constants.ENTITY_TYPE_PROPERTY_KEY, typeName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
…nt BM applicability is enforced across subtype inheritance etc.
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