Skip to content

Commit ce9f94b

Browse files
authored
Permit AccessDeniedException while listing blobs (#88802)
On Windows it's possible to get an `AccessDeniedException` while listing blobs in the presence of concurrent deletions. Today this causes things like a snapshot delete to fail, but we should accept the exception and move on. Closes #88716
1 parent 23cd8c5 commit ce9f94b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

server/src/internalClusterTest/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ public void testDeleteIndexDuringSnapshot() throws Exception {
11921192
assertAcked(admin().indices().prepareDelete(indexName));
11931193

11941194
for (Future<Void> future : futures) {
1195-
future.get();
1195+
future.get(30, TimeUnit.SECONDS);
11961196
}
11971197

11981198
logger.info("--> restore snapshot 1");

server/src/main/java/org/elasticsearch/common/blobstore/fs/FsBlobContainer.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
package org.elasticsearch.common.blobstore.fs;
1010

11+
import org.apache.logging.log4j.LogManager;
12+
import org.apache.logging.log4j.Logger;
13+
import org.apache.lucene.util.Constants;
1114
import org.elasticsearch.common.UUIDs;
1215
import org.elasticsearch.common.blobstore.BlobContainer;
1316
import org.elasticsearch.common.blobstore.BlobPath;
@@ -19,13 +22,15 @@
1922
import org.elasticsearch.common.io.Streams;
2023
import org.elasticsearch.core.CheckedConsumer;
2124
import org.elasticsearch.core.IOUtils;
25+
import org.elasticsearch.core.Strings;
2226

2327
import java.io.FileNotFoundException;
2428
import java.io.IOException;
2529
import java.io.InputStream;
2630
import java.io.OutputStream;
2731
import java.nio.channels.Channels;
2832
import java.nio.channels.SeekableByteChannel;
33+
import java.nio.file.AccessDeniedException;
2934
import java.nio.file.DirectoryStream;
3035
import java.nio.file.FileAlreadyExistsException;
3136
import java.nio.file.FileVisitResult;
@@ -53,6 +58,8 @@
5358
*/
5459
public class FsBlobContainer extends AbstractBlobContainer {
5560

61+
private static final Logger logger = LogManager.getLogger(FsBlobContainer.class);
62+
5663
private static final String TEMP_FILE_PREFIX = "pending-";
5764

5865
protected final FsBlobStore blobStore;
@@ -94,7 +101,12 @@ public Map<String, BlobMetadata> listBlobsByPrefix(String blobNamePrefix) throws
94101
try {
95102
attrs = Files.readAttributes(file, BasicFileAttributes.class);
96103
} catch (FileNotFoundException | NoSuchFileException e) {
97-
// The file was concurrently deleted between listing files and trying to get its attributes so we skip it here
104+
// The file was concurrently deleted trying to get its attributes so we skip it here
105+
continue;
106+
} catch (AccessDeniedException e) {
107+
// The file became inaccessible for some reason, possibly an artefact of concurrent deletion (Windows?): warn and skip
108+
logger.warn(Strings.format("file [%s] became inaccessible while listing [%s/%s]", file, path, blobNamePrefix), e);
109+
assert Constants.WINDOWS : e;
98110
continue;
99111
}
100112
if (attrs.isRegularFile()) {

0 commit comments

Comments
 (0)