kafka icon indicating copy to clipboard operation
kafka copied to clipboard

KAFKA-19971: Fix IllegalStateException from using entries after cache eviction

Open nandini12396 opened this issue 1 month ago • 0 comments

When the index cache is full and evicts entries, there's a race:

  1. Entry marked for cleanup (markedForCleanup=true)
  2. Index files renamed to .deleted
  3. Entry may still be in Caffeine cache (async eviction)
  4. cache.get() returns this marked entry
  5. Cleanup runs after delay → cleanStarted=true
  6. Subsequent lookups throw IllegalStateException

This fix detects entries with markedForCleanup=true in getIndexEntry(), invalidates them, and refetches from remote storage as a cache miss.

nandini12396 avatar Dec 05 '25 11:12 nandini12396