Skip to content

Add More Trace Logging to BlobStoreRepository #56336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ private void asyncCleanupUnlinkedShardLevelBlobs(Collection<SnapshotId> snapshot
listener,
l -> {
try {
blobContainer().deleteBlobsIgnoringIfNotExists(resolveFilesToDelete(snapshotIds, deleteResults));
deleteFromContainer(blobContainer(), resolveFilesToDelete(snapshotIds, deleteResults));
l.onResponse(null);
} catch (Exception e) {
logger.warn(
Expand Down Expand Up @@ -911,7 +911,7 @@ private List<String> cleanupStaleRootFiles(Collection<SnapshotId> deletedSnapsho
logger.info("[{}] Found stale root level blobs {}. Cleaning them up", metadata.name(), blobsToLog);
}
}
blobContainer().deleteBlobsIgnoringIfNotExists(blobsToDelete);
deleteFromContainer(blobContainer(), blobsToDelete);
return blobsToDelete;
} catch (IOException e) {
logger.warn(() -> new ParameterizedMessage(
Expand Down Expand Up @@ -1030,7 +1030,7 @@ private void cleanupOldShardGens(RepositoryData existingRepositoryData, Reposito
(indexId, gens) -> gens.forEach((shardId, oldGen) -> toDelete.add(
shardContainer(indexId, shardId).path().buildAsString().substring(prefixPathLen) + INDEX_FILE_PREFIX + oldGen)));
try {
blobContainer().deleteBlobsIgnoringIfNotExists(toDelete);
deleteFromContainer(blobContainer(), toDelete);
} catch (Exception e) {
logger.warn("Failed to clean up old shard generation blobs", e);
}
Expand Down Expand Up @@ -1067,6 +1067,11 @@ public IndexMetadata getSnapshotIndexMetadata(final SnapshotId snapshotId, final
}
}

private void deleteFromContainer(BlobContainer container, List<String> blobs) throws IOException {
logger.trace(() -> new ParameterizedMessage("[{}] Deleting {} from [{}]", metadata.name(), blobs, container.path()));
container.deleteBlobsIgnoringIfNotExists(blobs);
}

private BlobPath indicesPath() {
return basePath().add("indices");
}
Expand Down Expand Up @@ -1538,7 +1543,7 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS
.mapToObj(gen -> INDEX_FILE_PREFIX + gen)
.collect(Collectors.toList());
try {
blobContainer().deleteBlobsIgnoringIfNotExists(oldIndexN);
deleteFromContainer(blobContainer(), oldIndexN);
} catch (IOException e) {
logger.warn(() -> new ParameterizedMessage("Failed to clean up old index blobs {}", oldIndexN), e);
}
Expand Down Expand Up @@ -1618,6 +1623,8 @@ private long latestGeneration(Collection<String> rootBlobs) {

private void writeAtomic(final String blobName, final BytesReference bytesRef, boolean failIfAlreadyExists) throws IOException {
try (InputStream stream = bytesRef.streamInput()) {
logger.trace(() ->
new ParameterizedMessage("[{}] Writing [{}] to the base path atomically", metadata.name(), blobName));
blobContainer().writeBlobAtomic(blobName, stream, bytesRef.length(), failIfAlreadyExists);
}
}
Expand Down Expand Up @@ -1789,7 +1796,7 @@ public void snapshotShard(Store store, MapperService mapperService, SnapshotId s
}
if (writeShardGens == false) {
try {
shardContainer.deleteBlobsIgnoringIfNotExists(blobsToDelete);
deleteFromContainer(shardContainer, blobsToDelete);
} catch (IOException e) {
logger.warn(() -> new ParameterizedMessage("[{}][{}] failed to delete old index-N blobs during finalization",
snapshotId, shardId), e);
Expand Down Expand Up @@ -2033,6 +2040,8 @@ private void writeShardIndexBlob(BlobContainer shardContainer, String indexGener
BlobStoreIndexShardSnapshots updatedSnapshots) throws IOException {
assert ShardGenerations.NEW_SHARD_GEN.equals(indexGeneration) == false;
assert ShardGenerations.DELETED_SHARD_GEN.equals(indexGeneration) == false;
logger.trace(() -> new ParameterizedMessage("[{}] Writing shard index [{}] to [{}]", metadata.name(),
indexGeneration, shardContainer.path()));
indexShardSnapshotsFormat.writeAtomic(updatedSnapshots, shardContainer, indexGeneration);
}

Expand Down Expand Up @@ -2141,7 +2150,10 @@ private void checkAborted() {
}
}
};
shardContainer.writeBlob(fileInfo.partName(i), inputStream, partBytes, true);
final String partName = fileInfo.partName(i);
logger.trace(() ->
new ParameterizedMessage("[{}] Writing [{}] to [{}]", metadata.name(), partName, shardContainer.path()));
shardContainer.writeBlob(partName, inputStream, partBytes, true);
}
Store.verify(indexInput);
snapshotStatus.addProcessedFile(fileInfo.length());
Expand Down