zhang-arvin opened a new pull request, #13152:
URL: https://github.com/apache/gravitino/pull/13152

   ### What changes were proposed in this pull request?
   
   Fixes #13136
   
   `CaffeineEntityCache` maintains cached entities in `cacheData` and a 
hierarchy prefix index in `cacheIndex`. Its Caffeine removal listener runs 
asynchronously. If an old entry is removed (expiry/eviction) and the same key 
is reinserted before the listener runs, `invalidateExpiredItem()` previously 
removed the key from `cacheIndex` unconditionally — even though the new entry 
still exists in `cacheData`. A subsequent parent-level invalidation then cannot 
discover the child through the index, so the reinserted child remains cached.
   
   ### Why are the changes needed?
   
   The race silently diverges `cacheData` from `cacheIndex`, leaving stale 
entries that defeat hierarchical invalidation.
   
   ### Does this PR introduce any user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Added a deterministic regression test 
(`testExpiredRemovalCallbackAfterReinsertKeepsIndexEntry`): put 
catalog/schema/table with a 50 ms TTL, wait for the table entry to expire 
(`Awaitility`), reinsert it, then invalidate the catalog and assert the 
reinserted table is dropped (index entry was preserved). Existing invalidation 
test class still passes.


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