Skip to content

Commit 3f18769

Browse files
Log Warning on Failed Blob Deletes in BlobStoreRepository (#40188) (#40342)
* Log Warning on Failed Blob Deletes in BlobStoreRepository * We should not just debug log these spots, they all can and will lead to leaked files when snapshot deletion fails
1 parent 0dd8132 commit 3f18769

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -461,17 +461,17 @@ public void deleteSnapshot(SnapshotId snapshotId, long repositoryStateId) {
461461
final BlobContainer indicesBlobContainer = blobStore().blobContainer(basePath().add("indices"));
462462
for (final IndexId indexId : indicesToCleanUp) {
463463
try {
464-
indicesBlobContainer.deleteBlob(indexId.getId());
464+
indicesBlobContainer.deleteBlobIgnoringIfNotExists(indexId.getId());
465465
} catch (DirectoryNotEmptyException dnee) {
466466
// if the directory isn't empty for some reason, it will fail to clean up;
467467
// we'll ignore that and accept that cleanup didn't fully succeed.
468468
// since we are using UUIDs for path names, this won't be an issue for
469469
// snapshotting indices of the same name
470-
logger.debug(() -> new ParameterizedMessage("[{}] index [{}] no longer part of any snapshots in the repository, " +
470+
logger.warn(() -> new ParameterizedMessage("[{}] index [{}] no longer part of any snapshots in the repository, " +
471471
"but failed to clean up its index folder due to the directory not being empty.", metadata.name(), indexId), dnee);
472472
} catch (IOException ioe) {
473473
// a different IOException occurred while trying to delete - will just log the issue for now
474-
logger.debug(() -> new ParameterizedMessage("[{}] index [{}] no longer part of any snapshots in the repository, " +
474+
logger.warn(() -> new ParameterizedMessage("[{}] index [{}] no longer part of any snapshots in the repository, " +
475475
"but failed to clean up its index folder.", metadata.name(), indexId), ioe);
476476
}
477477
}
@@ -821,7 +821,7 @@ private long listBlobsToGetLatestIndexId() throws IOException {
821821
} catch (NumberFormatException nfe) {
822822
// the index- blob wasn't of the format index-N where N is a number,
823823
// no idea what this blob is but it doesn't belong in the repository!
824-
logger.debug("[{}] Unknown blob in the repository: {}", metadata.name(), blobName);
824+
logger.warn("[{}] Unknown blob in the repository: {}", metadata.name(), blobName);
825825
}
826826
}
827827
return latest;
@@ -964,7 +964,7 @@ public void delete() {
964964
try {
965965
indexShardSnapshotFormat.delete(blobContainer, snapshotId.getUUID());
966966
} catch (IOException e) {
967-
logger.debug("[{}] [{}] failed to delete shard snapshot file", shardId, snapshotId);
967+
logger.warn(new ParameterizedMessage("[{}] [{}] failed to delete shard snapshot file", shardId, snapshotId), e);
968968
}
969969

970970
// Build a list of snapshots that should be preserved
@@ -1124,7 +1124,7 @@ protected Tuple<BlobStoreIndexShardSnapshots, Integer> buildBlobStoreIndexShardS
11241124
logger.warn(() -> new ParameterizedMessage("failed to read index file [{}]", file), e);
11251125
}
11261126
} else if (blobKeys.isEmpty() == false) {
1127-
logger.debug("Could not find a readable index-N file in a non-empty shard snapshot directory [{}]", blobContainer.path());
1127+
logger.warn("Could not find a readable index-N file in a non-empty shard snapshot directory [{}]", blobContainer.path());
11281128
}
11291129

11301130
// We couldn't load the index file - falling back to loading individual snapshots

0 commit comments

Comments
 (0)