LuciferYang opened a new issue, #13399:
URL: https://github.com/apache/gravitino/issues/13399

   ### Version
   
   main branch
   
   ### Describe what's wrong
   
   `SegmentedLock.withGlobalLock` is documented to give the action exclusive 
access to all segments, but it acquires no segment lock. It only flips a latch 
that new `withLock` callers check on entry, so a thread that is already past 
that check, or inside its critical section, runs concurrently with the global 
action.
   
   In `CaffeineEntityCache`, `clear()` uses `withGlobalLock` while it swaps in 
a fresh index tree. A `doPut` racing that `clear()` can read the old 
`cacheIndex` field and write its entry into the `RadixTree` that `clear()` is 
about to replace, so the entity ends up present in `cacheData` but absent from 
the active `cacheIndex`. Later hierarchy invalidations scan the new tree, miss 
it, and the stale entry is served until it expires by TTL.
   
   ### How to reproduce
   
   Race `CaffeineEntityCache.clear()` (reachable from 
`EntityCacheChangeLogListener`'s fallback path when a replay-invalidate fails) 
against a concurrent `put`. The entity can be left in `cacheData` while missing 
from the active index, and subsequent invalidations for its hierarchy do not 
remove it.
   


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