Skip to content

Commit cc7680c

Browse files
Log Warning on Failed Blob Deletes in BlobStoreRepository (#40188) (#40341)
* 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 3171bef commit cc7680c

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
@@ -466,17 +466,17 @@ public void deleteSnapshot(SnapshotId snapshotId, long repositoryStateId) {
466466
final BlobContainer indicesBlobContainer = blobStore().blobContainer(basePath().add("indices"));
467467
for (final IndexId indexId : indicesToCleanUp) {
468468
try {
469-
indicesBlobContainer.deleteBlob(indexId.getId());
469+
indicesBlobContainer.deleteBlobIgnoringIfNotExists(indexId.getId());
470470
} catch (DirectoryNotEmptyException dnee) {
471471
// if the directory isn't empty for some reason, it will fail to clean up;
472472
// we'll ignore that and accept that cleanup didn't fully succeed.
473473
// since we are using UUIDs for path names, this won't be an issue for
474474
// snapshotting indices of the same name
475-
logger.debug(() -> new ParameterizedMessage("[{}] index [{}] no longer part of any snapshots in the repository, " +
475+
logger.warn(() -> new ParameterizedMessage("[{}] index [{}] no longer part of any snapshots in the repository, " +
476476
"but failed to clean up its index folder due to the directory not being empty.", metadata.name(), indexId), dnee);
477477
} catch (IOException ioe) {
478478
// a different IOException occurred while trying to delete - will just log the issue for now
479-
logger.debug(() -> new ParameterizedMessage("[{}] index [{}] no longer part of any snapshots in the repository, " +
479+
logger.warn(() -> new ParameterizedMessage("[{}] index [{}] no longer part of any snapshots in the repository, " +
480480
"but failed to clean up its index folder.", metadata.name(), indexId), ioe);
481481
}
482482
}
@@ -826,7 +826,7 @@ private long listBlobsToGetLatestIndexId() throws IOException {
826826
} catch (NumberFormatException nfe) {
827827
// the index- blob wasn't of the format index-N where N is a number,
828828
// no idea what this blob is but it doesn't belong in the repository!
829-
logger.debug("[{}] Unknown blob in the repository: {}", metadata.name(), blobName);
829+
logger.warn("[{}] Unknown blob in the repository: {}", metadata.name(), blobName);
830830
}
831831
}
832832
return latest;
@@ -969,7 +969,7 @@ public void delete() {
969969
try {
970970
indexShardSnapshotFormat.delete(blobContainer, snapshotId.getUUID());
971971
} catch (IOException e) {
972-
logger.debug("[{}] [{}] failed to delete shard snapshot file", shardId, snapshotId);
972+
logger.warn(new ParameterizedMessage("[{}] [{}] failed to delete shard snapshot file", shardId, snapshotId), e);
973973
}
974974

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

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

0 commit comments

Comments
 (0)