Skip to content

Commit

Permalink
Remove Exists Check from S3 Repository Deletes (#40931)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
original-brownbear authored Apr 25, 2019
1 parent 9bf8b5a commit 180deaa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ public void writeBlobAtomic(String blobName, InputStream inputStream, long blobS

@Override
public void deleteBlob(String blobName) throws IOException {
if (blobExists(blobName) == false) {
throw new NoSuchFileException("Blob [" + blobName + "] does not exist");
}
deleteBlobIgnoringIfNotExists(blobName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ protected BlobStore newBlobStore() {
return randomMockS3BlobStore();
}

@Override
public void testDeleteBlob() {
assumeFalse("not implemented because of S3's weak consistency model", true);
}

@Override
public void testVerifyOverwriteFails() {
assumeFalse("not implemented because of S3's weak consistency model", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public interface BlobContainer {

/**
* Deletes the blob with the given name, if the blob exists. If the blob does not exist,
* this method throws a NoSuchFileException.
* this method may throw a {@link NoSuchFileException} if the underlying implementation supports an existence check before delete.
*
* @param blobName
* The name of the blob to delete.
Expand All @@ -120,9 +120,7 @@ default void deleteBlobsIgnoringIfNotExists(List<String> blobNames) throws IOExc
IOException ioe = null;
for (String blobName : blobNames) {
try {
deleteBlob(blobName);
} catch (NoSuchFileException e) {
// ignored
deleteBlobIgnoringIfNotExists(blobName);
} catch (IOException e) {
if (ioe == null) {
ioe = e;
Expand Down

0 comments on commit 180deaa

Please sign in to comment.