Caideyipi commented on code in PR #18648:
URL: https://github.com/apache/iotdb/pull/18648#discussion_r4032472791


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/AuthorityChecker.java:
##########
@@ -131,13 +131,15 @@ public static IAuthorityFetcher getAuthorityFetcher() {
   }
 
   public static boolean invalidateCache(String username, String roleName) {
+    final boolean invalidated =
+        authorityFetcher.get().getAuthorCache().invalidateCache(username, 
roleName);

Review Comment:
   **[P1] Guard authority-cache refills with an invalidation generation**
   
   Reordering these invalidations only removes matcher entries produced by an 
in-flight match; it does not prevent the underlying authority cache from being 
refilled after its invalidation. A matcher miss holds the matcher read lock 
while `checkCanSelectFromTable4Pipe()` may issue a ConfigNode RPC. If a 
pre-revocation successful response returns after the author cache is cleared, 
`ClusterAuthorityFetcher.checkPrivilegeFromConfigNode()` can call 
`putUserCache()` with the old `User` while this thread is waiting for the 
matcher write lock. The following matcher invalidation then clears only the 
matcher entry, leaving the stale authority entry behind; the next event 
repopulates the matcher and a busy pipe can continue passing a revoked user.
   
   Please add a generation/epoch to authority-cache loads (capture it before 
the RPC and only install the response if unchanged), or otherwise coordinate 
refills atomically with both invalidations. A latch-based test for this exact 
interleaving would prevent regression.
   



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