From 4e41814a2ce504295702c4d4d9cc1b0a801ea0cb Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Thu, 21 Mar 2019 14:58:37 +0100 Subject: [PATCH] Log Warning on Failed Blob Deletes in BlobStoreRepository (#40188) * 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 --- .../repositories/blobstore/BlobStoreRepository.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java b/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java index 8858f46a39e82..c6eb7e5c6c293 100644 --- a/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java +++ b/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java @@ -466,17 +466,17 @@ public void deleteSnapshot(SnapshotId snapshotId, long repositoryStateId) { final BlobContainer indicesBlobContainer = blobStore().blobContainer(basePath().add("indices")); for (final IndexId indexId : indicesToCleanUp) { try { - indicesBlobContainer.deleteBlob(indexId.getId()); + indicesBlobContainer.deleteBlobIgnoringIfNotExists(indexId.getId()); } catch (DirectoryNotEmptyException dnee) { // if the directory isn't empty for some reason, it will fail to clean up; // we'll ignore that and accept that cleanup didn't fully succeed. // since we are using UUIDs for path names, this won't be an issue for // snapshotting indices of the same name - logger.debug(() -> new ParameterizedMessage("[{}] index [{}] no longer part of any snapshots in the repository, " + + logger.warn(() -> new ParameterizedMessage("[{}] index [{}] no longer part of any snapshots in the repository, " + "but failed to clean up its index folder due to the directory not being empty.", metadata.name(), indexId), dnee); } catch (IOException ioe) { // a different IOException occurred while trying to delete - will just log the issue for now - logger.debug(() -> new ParameterizedMessage("[{}] index [{}] no longer part of any snapshots in the repository, " + + logger.warn(() -> new ParameterizedMessage("[{}] index [{}] no longer part of any snapshots in the repository, " + "but failed to clean up its index folder.", metadata.name(), indexId), ioe); } } @@ -826,7 +826,7 @@ private long listBlobsToGetLatestIndexId() throws IOException { } catch (NumberFormatException nfe) { // the index- blob wasn't of the format index-N where N is a number, // no idea what this blob is but it doesn't belong in the repository! - logger.debug("[{}] Unknown blob in the repository: {}", metadata.name(), blobName); + logger.warn("[{}] Unknown blob in the repository: {}", metadata.name(), blobName); } } return latest; @@ -969,7 +969,7 @@ public void delete() { try { indexShardSnapshotFormat.delete(blobContainer, snapshotId.getUUID()); } catch (IOException e) { - logger.debug("[{}] [{}] failed to delete shard snapshot file", shardId, snapshotId); + logger.warn(new ParameterizedMessage("[{}] [{}] failed to delete shard snapshot file", shardId, snapshotId), e); } // Build a list of snapshots that should be preserved @@ -1129,7 +1129,7 @@ protected Tuple buildBlobStoreIndexShardS logger.warn(() -> new ParameterizedMessage("failed to read index file [{}]", file), e); } } else if (blobKeys.isEmpty() == false) { - logger.debug("Could not find a readable index-N file in a non-empty shard snapshot directory [{}]", blobContainer.path()); + logger.warn("Could not find a readable index-N file in a non-empty shard snapshot directory [{}]", blobContainer.path()); } // We couldn't load the index file - falling back to loading individual snapshots