Skip to content

Commit

Permalink
code comments only
Browse files Browse the repository at this point in the history
Signed-off-by: Kiran Prakash <[email protected]>
  • Loading branch information
kiranprakash154 committed Apr 10, 2024
1 parent e14a54c commit 3a2e852
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ BytesReference getOrCompute(
if (logger.isDebugEnabled()) {
logger.debug("cleanupKey in Indices Request Cache failed to register close listener due to : " + e.getCause());
}
// On failing to register the cleanupkey, this cache entry is immediately stale and could live indefinitely
// hence enqueuing it to clean-up
// On failing to register the cleanupkey, this cache entry is immediately stale and could live indefinitely in the cache
// hence enqueuing it for clean-up
cacheCleanupManager.updateCleanupKeyToCountMapOnCacheInsertion(cleanupKey);
cacheCleanupManager.enqueueCleanupKey(cleanupKey);
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,9 @@ public void testCleanupKeyToCountMapAreSetAppropriately() throws Exception {
assertEquals(0, cleanupKeyToCountMap.size());
}

// test the cleanupKeyToCountMap are set appropriately when readers are closed
// test the cleanupKeyToCountMap are set appropriately in a case where the reader gets closed
// after putting an entry into the cache and before registering a close listener
// in this case, the entry is stale and needs to be accounted right and cleaned up accordingly
public void testCleanupKeyToOnClosedReader_cleansupStalenessAsExpected() throws Exception {
threadPool = getThreadPool();
Settings settings = Settings.builder()
Expand All @@ -670,6 +672,7 @@ public void testCleanupKeyToOnClosedReader_cleansupStalenessAsExpected() throws

assertTrue(cache.cacheCleanupManager.getCleanupKeyToCountMap().isEmpty());
try {
// use auto close loader to close the reader right after adding cache entry
cache.getOrCompute(getEntity(indexShard), getAutoCloseLoader(reader), reader, getTermBytes());
} catch (Exception e) {
assertThat(e, instanceOf(AlreadyClosedException.class));
Expand Down

0 comments on commit 3a2e852

Please sign in to comment.