diff --git a/server/src/main/java/org/elasticsearch/common/blobstore/fs/FsBlobContainer.java b/server/src/main/java/org/elasticsearch/common/blobstore/fs/FsBlobContainer.java index d333691a9bc26..d3a9731b2f656 100644 --- a/server/src/main/java/org/elasticsearch/common/blobstore/fs/FsBlobContainer.java +++ b/server/src/main/java/org/elasticsearch/common/blobstore/fs/FsBlobContainer.java @@ -97,7 +97,13 @@ public Map listBlobsByPrefix(String blobNamePrefix) throws blobNamePrefix = blobNamePrefix == null ? "" : blobNamePrefix; try (DirectoryStream stream = Files.newDirectoryStream(path, blobNamePrefix + "*")) { for (Path file : stream) { - final BasicFileAttributes attrs = Files.readAttributes(file, BasicFileAttributes.class); + final BasicFileAttributes attrs; + try { + attrs = Files.readAttributes(file, BasicFileAttributes.class); + } catch (FileNotFoundException | NoSuchFileException e) { + // The file was concurrently deleted between listing files and trying to get its attributes so we skip it here + continue; + } if (attrs.isRegularFile()) { builder.put(file.getFileName().toString(), new PlainBlobMetaData(file.getFileName().toString(), attrs.size())); }