Skip to content

Commit

Permalink
Revert attempt to clean cache
Browse files Browse the repository at this point in the history
Signed-off-by: Finn Carroll <carrofin@amazon.com>
  • Loading branch information
finnegancarroll committed Aug 5, 2024
1 parent 6f86ed4 commit 38b3b95
Showing 1 changed file with 3 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,27 +96,12 @@ public IndexInput fetchBlob(BlobFetchRequest blobFetchRequest) throws IOExceptio
@SuppressWarnings("removal")
private static FileCachedIndexInput createIndexInput(FileCache fileCache, StreamReader streamReader, BlobFetchRequest request) {
try {
// This local file cache is ref counted and may not strictly enforce capacity.
// In our use case capacity directly relates to disk usage.
// If we find available capacity is exceeded deny further BlobFetchRequests.
// This local file cache is ref counted and may not strictly enforce configured capacity.
// If we find available capacity is exceeded, deny further BlobFetchRequests.
Supplier<Short> cacheUsagePerc = () ->
fileCache.capacity() <= 0 ? 0 : (short) (Math.round((100d * fileCache.usage().usage()) / fileCache.capacity()));

if (cacheUsagePerc.get() >= 99) {
System.gc();

// File reference cleanup is not immediate and is processed
// in a dedicated thread.
try {
Thread.sleep(10);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}

fileCache.prune();
if (cacheUsagePerc.get() >= 99) {
throw new IOException("Local file cache capacity exceeded - BlobFetchRequest failed: " + request.getFilePath());
}
throw new IOException("Local file cache capacity exceeded - BlobFetchRequest failed: " + request.getFilePath());
}
if (Files.exists(request.getFilePath()) == false) {
logger.trace("Fetching from Remote in createIndexInput of Transfer Manager");
Expand Down

0 comments on commit 38b3b95

Please sign in to comment.