From dd66d58f9495cb3df0f0909bbf92336793e57ac3 Mon Sep 17 00:00:00 2001 From: Himanshu Kakar Date: Wed, 20 Aug 2025 08:11:01 +0530 Subject: [PATCH 1/2] For the WarmIndex if the file deletion (which is triggered as part of creating the compound file) fails, we handle in the similar way as is done in FSDriectory, by asking the localDirectory to delete the file. The localDirectory if it fails, already has the mechanism to handle this by maintaining the file's info in pendingDeletes. The pending deletes are taken care later by retriggering the deletes. Signed-off-by: Himanshu Kakar --- .../opensearch/index/store/CompositeDirectory.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/index/store/CompositeDirectory.java b/server/src/main/java/org/opensearch/index/store/CompositeDirectory.java index cb95c31941a0e..4badfc6357c56 100644 --- a/server/src/main/java/org/opensearch/index/store/CompositeDirectory.java +++ b/server/src/main/java/org/opensearch/index/store/CompositeDirectory.java @@ -188,7 +188,18 @@ not present in remote as well (due to metadata refresh). In such scenarios listA logger.debug("The file [{}] exists in local but not part of FileCache, deleting it from local", blockFile); localDirectory.deleteFile(blockFile); } else { - fileCache.remove(getFilePath(blockFile)); + // here the file is to be deleted both from FileCache and the local directory. + Path blockFilePath = getFilePath(blockFile); + try { + fileCache.remove(blockFilePath); + }catch(Exception e){ + if (e.getCause() instanceof AccessDeniedException) { + localDirectory.deleteFile(blockFile); + } else { + logger.error("Exception while removing file [{}] from FileCache. Exception:", blockFilePath, e); + throw e; + } + } } } } From 026e3cdb579db1fa9b1ac6e9b300f56754e0486d Mon Sep 17 00:00:00 2001 From: Himanshu Kakar Date: Thu, 21 Aug 2025 14:05:18 +0530 Subject: [PATCH 2/2] added the missing import Signed-off-by: Himanshu Kakar --- .../main/java/org/opensearch/index/store/CompositeDirectory.java | 1 + 1 file changed, 1 insertion(+) diff --git a/server/src/main/java/org/opensearch/index/store/CompositeDirectory.java b/server/src/main/java/org/opensearch/index/store/CompositeDirectory.java index 4badfc6357c56..6da50e1e0ed86 100644 --- a/server/src/main/java/org/opensearch/index/store/CompositeDirectory.java +++ b/server/src/main/java/org/opensearch/index/store/CompositeDirectory.java @@ -32,6 +32,7 @@ import java.io.FileNotFoundException; import java.io.IOException; +import java.nio.file.AccessDeniedException; import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.nio.file.Path;