Skip to content

Commit 632afbc

Browse files
committed
Only evict asynchronously for shards we know are not coming back
1 parent 83c1bda commit 632afbc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotIndexEventListener.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,12 @@ public void beforeIndexRemoved(IndexService indexService, IndexRemovalReason rea
114114
);
115115
}
116116
if (indexSettings.getIndexMetadata().isPartialSearchableSnapshot() && sharedBlobCacheService != null) {
117-
sharedBlobCacheService.forceEvictAsync(
118-
SearchableSnapshots.forceEvictPredicate(shardId, indexSettings.getSettings())
119-
);
117+
// Evict shards we know are not coming back asynchronously. Let any other shards expire.
118+
switch (reason) {
119+
case DELETED, FAILURE -> sharedBlobCacheService.forceEvictAsync(
120+
SearchableSnapshots.forceEvictPredicate(shardId, indexSettings.getSettings())
121+
);
122+
}
120123
}
121124
}
122125
}

0 commit comments

Comments
 (0)