Skip to content

Commit 787c12a

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

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
@@ -679,7 +679,7 @@ private void asyncCleanupUnlinkedShardLevelBlobs(Collection<SnapshotId> snapshot
679679
listener,
680680
l -> {
681681
try {
682-
blobContainer().deleteBlobsIgnoringIfNotExists(resolveFilesToDelete(snapshotIds, deleteResults));
682+
deleteFromContainer(blobContainer(), resolveFilesToDelete(snapshotIds, deleteResults));
683683
l.onResponse(null);
684684
} catch (Exception e) {
685685
logger.warn(
@@ -911,7 +911,7 @@ private List<String> cleanupStaleRootFiles(Collection<SnapshotId> deletedSnapsho
911911
logger.info("[{}] Found stale root level blobs {}. Cleaning them up", metadata.name(), blobsToLog);
912912
}
913913
}
914-
blobContainer().deleteBlobsIgnoringIfNotExists(blobsToDelete);
914+
deleteFromContainer(blobContainer(), blobsToDelete);
915915
return blobsToDelete;
916916
} catch (IOException e) {
917917
logger.warn(() -> new ParameterizedMessage(
@@ -1030,7 +1030,7 @@ private void cleanupOldShardGens(RepositoryData existingRepositoryData, Reposito
10301030
(indexId, gens) -> gens.forEach((shardId, oldGen) -> toDelete.add(
10311031
shardContainer(indexId, shardId).path().buildAsString().substring(prefixPathLen) + INDEX_FILE_PREFIX + oldGen)));
10321032
try {
1033-
blobContainer().deleteBlobsIgnoringIfNotExists(toDelete);
1033+
deleteFromContainer(blobContainer(), toDelete);
10341034
} catch (Exception e) {
10351035
logger.warn("Failed to clean up old shard generation blobs", e);
10361036
}
@@ -1067,6 +1067,11 @@ public IndexMetadata getSnapshotIndexMetadata(final SnapshotId snapshotId, final
10671067
}
10681068
}
10691069

1070+
private void deleteFromContainer(BlobContainer container, List<String> blobs) throws IOException {
1071+
logger.trace(() -> new ParameterizedMessage("[{}] Deleting {} from [{}]", metadata.name(), blobs, container.path()));
1072+
container.deleteBlobsIgnoringIfNotExists(blobs);
1073+
}
1074+
10701075
private BlobPath indicesPath() {
10711076
return basePath().add("indices");
10721077
}
@@ -1538,7 +1543,7 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS
15381543
.mapToObj(gen -> INDEX_FILE_PREFIX + gen)
15391544
.collect(Collectors.toList());
15401545
try {
1541-
blobContainer().deleteBlobsIgnoringIfNotExists(oldIndexN);
1546+
deleteFromContainer(blobContainer(), oldIndexN);
15421547
} catch (IOException e) {
15431548
logger.warn(() -> new ParameterizedMessage("Failed to clean up old index blobs {}", oldIndexN), e);
15441549
}
@@ -1618,6 +1623,8 @@ private long latestGeneration(Collection<String> rootBlobs) {
16181623

16191624
private void writeAtomic(final String blobName, final BytesReference bytesRef, boolean failIfAlreadyExists) throws IOException {
16201625
try (InputStream stream = bytesRef.streamInput()) {
1626+
logger.trace(() ->
1627+
new ParameterizedMessage("[{}] Writing [{}] to the base path atomically", metadata.name(), blobName));
16211628
blobContainer().writeBlobAtomic(blobName, stream, bytesRef.length(), failIfAlreadyExists);
16221629
}
16231630
}
@@ -1789,7 +1796,7 @@ public void snapshotShard(Store store, MapperService mapperService, SnapshotId s
17891796
}
17901797
if (writeShardGens == false) {
17911798
try {
1792-
shardContainer.deleteBlobsIgnoringIfNotExists(blobsToDelete);
1799+
deleteFromContainer(shardContainer, blobsToDelete);
17931800
} catch (IOException e) {
17941801
logger.warn(() -> new ParameterizedMessage("[{}][{}] failed to delete old index-N blobs during finalization",
17951802
snapshotId, shardId), e);
@@ -2033,6 +2040,8 @@ private void writeShardIndexBlob(BlobContainer shardContainer, String indexGener
20332040
BlobStoreIndexShardSnapshots updatedSnapshots) throws IOException {
20342041
assert ShardGenerations.NEW_SHARD_GEN.equals(indexGeneration) == false;
20352042
assert ShardGenerations.DELETED_SHARD_GEN.equals(indexGeneration) == false;
2043+
logger.trace(() -> new ParameterizedMessage("[{}] Writing shard index [{}] to [{}]", metadata.name(),
2044+
indexGeneration, shardContainer.path()));
20362045
indexShardSnapshotsFormat.writeAtomic(updatedSnapshots, shardContainer, indexGeneration);
20372046
}
20382047

@@ -2141,7 +2150,10 @@ private void checkAborted() {
21412150
}
21422151
}
21432152
};
2144-
shardContainer.writeBlob(fileInfo.partName(i), inputStream, partBytes, true);
2153+
final String partName = fileInfo.partName(i);
2154+
logger.trace(() ->
2155+
new ParameterizedMessage("[{}] Writing [{}] to [{}]", metadata.name(), partName, shardContainer.path()));
2156+
shardContainer.writeBlob(partName, inputStream, partBytes, true);
21452157
}
21462158
Store.verify(indexInput);
21472159
snapshotStatus.addProcessedFile(fileInfo.length());

0 commit comments

Comments
 (0)