Skip to content

Commit

Permalink
Update IndicesRequestCache.java
Browse files Browse the repository at this point in the history
Signed-off-by: Kiran Prakash <awskiran@amazon.com>
  • Loading branch information
kiranprakash154 committed Apr 12, 2024
1 parent 31d9c54 commit 9aeb82d
Showing 1 changed file with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -509,19 +509,15 @@ private void updateStaleCountOnCacheInsert(CleanupKey cleanupKey) {
* @param notification RemovalNotification of the cache entry evicted
*/
private void updateStaleCountOnEntryRemoval(CleanupKey cleanupKey, RemovalNotification<Key, BytesReference> notification) {
if (cleanupKey.entity == null) {
/*
* on shard close, the shard is still lying around so this will only happen when the shard is deleted.
* we would have accounted this in staleKeysCount when the deletion of shard would have closed the associated readers
* */
staleKeysCount.decrementAndGet();
if (notification.getRemovalReason() == RemovalReason.REPLACED) {
// The reason of the notification is REPLACED when a cache entry's value is updated, since replacing an entry
// does not affect the staleness count, we skip such notifications.
return;
}
/*
* The reason of the notification is REPLACED when a cache entry's value is updated, since replacing an entry
* does not affect the staleness count, we skip such notifications.
* */
if (notification.getRemovalReason() == RemovalReason.REPLACED) {
if (cleanupKey.entity == null) {
// on shard close, the shard is still lying around so this will only happen when the shard is deleted.
// we would have accounted this in staleKeysCount when the deletion of shard would have closed the associated readers
staleKeysCount.decrementAndGet();
return;
}
IndexShard indexShard = (IndexShard) cleanupKey.entity.getCacheIdentity();
Expand Down

0 comments on commit 9aeb82d

Please sign in to comment.