kafka
kafka copied to clipboard
KAFKA-19971: Fix IllegalStateException from using entries after cache eviction
When the index cache is full and evicts entries, there's a race:
- Entry marked for cleanup (markedForCleanup=true)
- Index files renamed to .deleted
- Entry may still be in Caffeine cache (async eviction)
- cache.get() returns this marked entry
- Cleanup runs after delay → cleanStarted=true
- Subsequent lookups throw IllegalStateException
This fix detects entries with markedForCleanup=true in getIndexEntry(), invalidates them, and refetches from remote storage as a cache miss.