Skip to content

Commit

Permalink
Add logs to translog GC
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Kale <[email protected]>
  • Loading branch information
Sachin Kale committed Aug 20, 2024
1 parent 2e5dded commit b4c2030
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -595,20 +595,22 @@ public void trimUnreferencedReaders() throws IOException {

// This is to fail fast and avoid listing md files un-necessarily.
if (RemoteStoreUtils.isPinnedTimestampStateStale()) {
logger.warn("Skipping remote segment store garbage collection as last fetch of pinned timestamp is stale");
logger.warn("Skipping remote translog garbage collection as last fetch of pinned timestamp is stale");
return;
}

// Since remote generation deletion is async, this ensures that only one generation deletion happens at a time.
// Remote generations involves 2 async operations - 1) Delete translog generation files 2) Delete metadata files
// We try to acquire 2 permits and if we can not, we return from here itself.
if (remoteGenerationDeletionPermits.tryAcquire(REMOTE_DELETION_PERMITS) == false) {
logger.warn("Skipping remote translog garbage collection as failed to acquire the permits");
return;
}

ActionListener<List<BlobMetadata>> listMetadataFilesListener = new ActionListener<>() {
@Override
public void onResponse(List<BlobMetadata> blobMetadata) {
logger.warn("Metadata file size: " + blobMetadata.size());
List<String> metadataFiles = blobMetadata.stream().map(BlobMetadata::name).collect(Collectors.toList());
Set<Long> generationsToDelete = new HashSet<>();
try {
Expand Down Expand Up @@ -653,9 +655,13 @@ public void onResponse(List<BlobMetadata> blobMetadata) {
TimeValue.timeValueMillis(minimumAgeInMillis)
);

logger.warn("Metadata files to be deleted after filtering based on age: {}", metadataFilesToBeDeleted.size());

// 5. Filter out metadata files matching pinned timestamps
metadataFilesToBeDeleted.removeAll(implicitLockedFiles);

logger.warn("Metadata files to be deleted after filtering md files matching pinned timestamps: {}", metadataFilesToBeDeleted.size());

if (metadataFilesToBeDeleted.isEmpty()) {
logger.debug("No metadata files to delete");
remoteGenerationDeletionPermits.release(REMOTE_DELETION_PERMITS);
Expand Down Expand Up @@ -700,6 +706,7 @@ public void onResponse(List<BlobMetadata> blobMetadata) {
}
generationsToDelete.add(generation);
}
logger.warn("Generations to delete: {}", generationsToDelete.size());
if (generationsToDelete.isEmpty() == false) {
// 9. Delete stale generations
deleteRemoteGenerations(generationsToDelete);
Expand Down Expand Up @@ -732,6 +739,7 @@ public void onResponse(List<BlobMetadata> blobMetadata) {
} catch (Exception e) {
remoteGenerationDeletionPermits.release(REMOTE_DELETION_PERMITS);
}
logger.warn("In trimUnreferencedReaders, onResponse completed");
}

@Override
Expand Down

0 comments on commit b4c2030

Please sign in to comment.