Skip to content

Commit 085ff8c

Browse files
Add More Trace Logging to BlobStoreRepository (#56336) (#56401)
Adding more trace logging that would be helpful in understanding the precise order of blob-level operations if needed.
1 parent ceb0b0d commit 085ff8c

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ private void asyncCleanupUnlinkedShardLevelBlobs(Collection<SnapshotId> snapshot
702702
listener,
703703
l -> {
704704
try {
705-
blobContainer().deleteBlobsIgnoringIfNotExists(resolveFilesToDelete(snapshotIds, deleteResults));
705+
deleteFromContainer(blobContainer(), resolveFilesToDelete(snapshotIds, deleteResults));
706706
l.onResponse(null);
707707
} catch (Exception e) {
708708
logger.warn(
@@ -934,7 +934,7 @@ private List<String> cleanupStaleRootFiles(Collection<SnapshotId> deletedSnapsho
934934
logger.info("[{}] Found stale root level blobs {}. Cleaning them up", metadata.name(), blobsToLog);
935935
}
936936
}
937-
blobContainer().deleteBlobsIgnoringIfNotExists(blobsToDelete);
937+
deleteFromContainer(blobContainer(), blobsToDelete);
938938
return blobsToDelete;
939939
} catch (IOException e) {
940940
logger.warn(() -> new ParameterizedMessage(
@@ -1053,7 +1053,7 @@ private void cleanupOldShardGens(RepositoryData existingRepositoryData, Reposito
10531053
(indexId, gens) -> gens.forEach((shardId, oldGen) -> toDelete.add(
10541054
shardContainer(indexId, shardId).path().buildAsString().substring(prefixPathLen) + INDEX_FILE_PREFIX + oldGen)));
10551055
try {
1056-
blobContainer().deleteBlobsIgnoringIfNotExists(toDelete);
1056+
deleteFromContainer(blobContainer(), toDelete);
10571057
} catch (Exception e) {
10581058
logger.warn("Failed to clean up old shard generation blobs", e);
10591059
}
@@ -1090,6 +1090,11 @@ public IndexMetadata getSnapshotIndexMetadata(final SnapshotId snapshotId, final
10901090
}
10911091
}
10921092

1093+
private void deleteFromContainer(BlobContainer container, List<String> blobs) throws IOException {
1094+
logger.trace(() -> new ParameterizedMessage("[{}] Deleting {} from [{}]", metadata.name(), blobs, container.path()));
1095+
container.deleteBlobsIgnoringIfNotExists(blobs);
1096+
}
1097+
10931098
private BlobPath indicesPath() {
10941099
return basePath().add("indices");
10951100
}
@@ -1561,7 +1566,7 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS
15611566
.mapToObj(gen -> INDEX_FILE_PREFIX + gen)
15621567
.collect(Collectors.toList());
15631568
try {
1564-
blobContainer().deleteBlobsIgnoringIfNotExists(oldIndexN);
1569+
deleteFromContainer(blobContainer(), oldIndexN);
15651570
} catch (IOException e) {
15661571
logger.warn(() -> new ParameterizedMessage("Failed to clean up old index blobs {}", oldIndexN), e);
15671572
}
@@ -1641,6 +1646,8 @@ private long latestGeneration(Collection<String> rootBlobs) {
16411646

16421647
private void writeAtomic(final String blobName, final BytesReference bytesRef, boolean failIfAlreadyExists) throws IOException {
16431648
try (InputStream stream = bytesRef.streamInput()) {
1649+
logger.trace(() ->
1650+
new ParameterizedMessage("[{}] Writing [{}] to the base path atomically", metadata.name(), blobName));
16441651
blobContainer().writeBlobAtomic(blobName, stream, bytesRef.length(), failIfAlreadyExists);
16451652
}
16461653
}
@@ -1812,7 +1819,7 @@ public void snapshotShard(Store store, MapperService mapperService, SnapshotId s
18121819
}
18131820
if (writeShardGens == false) {
18141821
try {
1815-
shardContainer.deleteBlobsIgnoringIfNotExists(blobsToDelete);
1822+
deleteFromContainer(shardContainer, blobsToDelete);
18161823
} catch (IOException e) {
18171824
logger.warn(() -> new ParameterizedMessage("[{}][{}] failed to delete old index-N blobs during finalization",
18181825
snapshotId, shardId), e);
@@ -2056,6 +2063,8 @@ private void writeShardIndexBlob(BlobContainer shardContainer, String indexGener
20562063
BlobStoreIndexShardSnapshots updatedSnapshots) throws IOException {
20572064
assert ShardGenerations.NEW_SHARD_GEN.equals(indexGeneration) == false;
20582065
assert ShardGenerations.DELETED_SHARD_GEN.equals(indexGeneration) == false;
2066+
logger.trace(() -> new ParameterizedMessage("[{}] Writing shard index [{}] to [{}]", metadata.name(),
2067+
indexGeneration, shardContainer.path()));
20592068
indexShardSnapshotsFormat.writeAtomic(updatedSnapshots, shardContainer, indexGeneration);
20602069
}
20612070

@@ -2164,7 +2173,10 @@ private void checkAborted() {
21642173
}
21652174
}
21662175
};
2167-
shardContainer.writeBlob(fileInfo.partName(i), inputStream, partBytes, true);
2176+
final String partName = fileInfo.partName(i);
2177+
logger.trace(() ->
2178+
new ParameterizedMessage("[{}] Writing [{}] to [{}]", metadata.name(), partName, shardContainer.path()));
2179+
shardContainer.writeBlob(partName, inputStream, partBytes, true);
21682180
}
21692181
Store.verify(indexInput);
21702182
snapshotStatus.addProcessedFile(fileInfo.length());

0 commit comments

Comments
 (0)