unknowntpo commented on code in PR #8297:
URL: https://github.com/apache/gravitino/pull/8297#discussion_r2306035002


##########
core/src/main/java/org/apache/gravitino/cache/CaffeineEntityCache.java:
##########
@@ -339,6 +364,55 @@ private boolean invalidateEntities(NameIdentifier 
identifier) {
     List<EntityCacheKey> entityKeysToRemove =
         
Lists.newArrayList(cacheIndex.getValuesForKeysStartingWith(identifier.toString()));
 
+    Map<EntityCacheRelationKey, List<Entity>> relationEnitiesMap =
+        cacheData.getAllPresent(entityKeysToRemove);
+
+    // SCENE[1]
+    // RECORD1 = Role1 -> [catalog1, catalog2]
+    // RECORD2 = catalog1 -> [tab1, tab2]
+    // INVALIDATE Role1, then need to remove RECORD1 and RECORD2
+    relationEnitiesMap.forEach(
+        (key, entities) -> {
+          if (key.relationType() == null) {
+            // If the relation type is null, it means it's a single entity, we 
can skip it.
+            return;
+          }
+          entities.forEach(
+              entity -> {
+                NameIdentifier child = getNameIdentifier(entity);
+                if (!child.equals(identifier)) {
+                  invalidateEntities(child);

Review Comment:
   Failed test: 
https://github.com/apache/gravitino/actions/runs/17262756741/job/48987812078?pr=8297#step:9:3663



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to