Skip to content

Commit 180deaa

Browse files
Remove Exists Check from S3 Repository Deletes (#40931)
* The check doesn't add much if anything practically, since the S3 repository is eventually consistent and we only log the non-existence of a blob anyway * We don't do the check on writes for this very reason and documented it as such * Removing the check saves one API call per single delete speeding up the deletion process and lowering costs
1 parent 9bf8b5a commit 180deaa

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

plugins/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3BlobContainer.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,6 @@ public void writeBlobAtomic(String blobName, InputStream inputStream, long blobS
119119

120120
@Override
121121
public void deleteBlob(String blobName) throws IOException {
122-
if (blobExists(blobName) == false) {
123-
throw new NoSuchFileException("Blob [" + blobName + "] does not exist");
124-
}
125122
deleteBlobIgnoringIfNotExists(blobName);
126123
}
127124

plugins/repository-s3/src/test/java/org/elasticsearch/repositories/s3/S3BlobStoreContainerTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ protected BlobStore newBlobStore() {
6565
return randomMockS3BlobStore();
6666
}
6767

68+
@Override
69+
public void testDeleteBlob() {
70+
assumeFalse("not implemented because of S3's weak consistency model", true);
71+
}
72+
6873
@Override
6974
public void testVerifyOverwriteFails() {
7075
assumeFalse("not implemented because of S3's weak consistency model", true);

server/src/main/java/org/elasticsearch/common/blobstore/BlobContainer.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public interface BlobContainer {
100100

101101
/**
102102
* Deletes the blob with the given name, if the blob exists. If the blob does not exist,
103-
* this method throws a NoSuchFileException.
103+
* this method may throw a {@link NoSuchFileException} if the underlying implementation supports an existence check before delete.
104104
*
105105
* @param blobName
106106
* The name of the blob to delete.
@@ -120,9 +120,7 @@ default void deleteBlobsIgnoringIfNotExists(List<String> blobNames) throws IOExc
120120
IOException ioe = null;
121121
for (String blobName : blobNames) {
122122
try {
123-
deleteBlob(blobName);
124-
} catch (NoSuchFileException e) {
125-
// ignored
123+
deleteBlobIgnoringIfNotExists(blobName);
126124
} catch (IOException e) {
127125
if (ioe == null) {
128126
ioe = e;

0 commit comments

Comments
 (0)