yuqi1129 commented on code in PR #12445:
URL: https://github.com/apache/gravitino/pull/12445#discussion_r3773759630


##########
server-common/src/main/java/org/apache/gravitino/server/authorization/jcasbin/JcasbinChangeListener.java:
##########
@@ -275,7 +280,17 @@ public synchronized void 
onEntityChange(List<EntityChangeRecord> changes) {
         leafKeys.add(cacheKey);
       }
     }
-    invalidateCoalescedKeys(containerPrefixes, leafKeys);
+    try {
+      invalidateCoalescedKeys(containerPrefixes, leafKeys);
+    } catch (RuntimeException e) {
+      LOG.error(
+          "Failed to invalidate {} prefix(es) and {} leaf key(s) from the 
entity change log, "
+              + "clearing the whole metadata id cache to stay coherent",
+          containerPrefixes.size(),
+          leafKeys.size(),
+          e);
+      metadataIdCache.invalidateAll();
+    }

Review Comment:
   Fixed in 71d24457ce. Prefix/leaf invalidation and the recovery 
invalidateAll() now run inside the same runInvalidationBatch callback, so 
readers cannot observe a partially invalidated cache before the full clear. If 
the batch mechanism fails before invoking the callback, the listener falls back 
to an unlocked full clear; if the in-lock clear itself fails, the exception 
still propagates. The tests now assert both the in-batch recovery path and the 
batch-start fallback.



-- 
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