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

   ### Version
   
   main branch
   
   ### Describe what is wrong
   
   `CaffeineEntityCache` maintains cached entities in `cacheData` and a 
hierarchy index in `cacheIndex`. Its removal listener runs asynchronously.
   
   If an old entry is removed and the same key is reinserted before the 
listener runs, `invalidateExpiredItem()` unconditionally removes the key from 
`cacheIndex`, even though the new entry still exists in `cacheData`. A 
subsequent parent-level invalidation cannot discover the child through the 
index, so the child remains cached.
   
   This race predates #13099 and was identified while reviewing that PR.
   
   ### Error message and/or stacktrace
   
   No exception is produced. The failure manifests as divergence between 
`cacheData` and `cacheIndex`.
   
   ### How to reproduce
   
   1. Insert a child entity into the cache.
   2. Trigger expiration or eviction of that entry.
   3. Reinsert the same key before its asynchronous removal listener executes.
   4. Allow the old removal callback to run.
   5. Invalidate the parent entity.
   6. Observe that the reinserted child remains in `cacheData` because its 
index entry was removed.
   
   ### Additional context
   
   The listener should remove the index entry only when the key is no longer 
present in `cacheData`, while holding the corresponding segmented lock.
   
   A deterministic regression test should simulate a delayed removal callback 
followed by reinsertion.
   
   Related: #12377, #13099.


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