diff --git a/server/src/main/java/org/opensearch/index/translog/RemoteFsTranslog.java b/server/src/main/java/org/opensearch/index/translog/RemoteFsTranslog.java index f330b92963f56..828a7ab36c65c 100644 --- a/server/src/main/java/org/opensearch/index/translog/RemoteFsTranslog.java +++ b/server/src/main/java/org/opensearch/index/translog/RemoteFsTranslog.java @@ -749,9 +749,10 @@ protected Set getGenerationsToBeDeleted( if (RemoteStoreSettings.isPinnedTimestampsEnabled()) { String latestMetadataFileToBeDeleted = metadataFilesToBeDeleted.get(0); - long maxGenerationFromLatestMetadataFile = metadataFileGenerationMap.containsKey(latestMetadataFileToBeDeleted) - ? metadataFileGenerationMap.get(latestMetadataFileToBeDeleted).v2() - : getMinMaxTranslogGenerationFromMetadataFile(latestMetadataFileToBeDeleted, translogTransferManager).v2(); + long maxGenerationFromLatestMetadataFile = getMinMaxTranslogGenerationFromMetadataFile( + latestMetadataFileToBeDeleted, + translogTransferManager + ).v2(); if (indexDeleted) { maxGenerationToBeDeleted = maxGenerationFromLatestMetadataFile; @@ -762,9 +763,8 @@ protected Set getGenerationsToBeDeleted( // From the remaining files, read the oldest file to get min generation to be deleted String oldestMetadataFileToBeDeleted = metadataFilesToBeDeleted.get(metadataFilesToBeDeleted.size() - 1); - long minGenerationToBeDeleted = metadataFileGenerationMap.containsKey(oldestMetadataFileToBeDeleted) - ? metadataFileGenerationMap.get(oldestMetadataFileToBeDeleted).v1() - : getMinMaxTranslogGenerationFromMetadataFile(oldestMetadataFileToBeDeleted, translogTransferManager).v1(); + long minGenerationToBeDeleted = getMinMaxTranslogGenerationFromMetadataFile(oldestMetadataFileToBeDeleted, translogTransferManager) + .v1(); TreeSet> pinnedGenerations = getOrderedPinnedMetadataGenerations(metadataFileGenerationMap); for (long generation = maxGenerationToBeDeleted; generation >= minGenerationToBeDeleted; generation--) { diff --git a/server/src/main/java/org/opensearch/index/translog/transfer/TranslogTransferManager.java b/server/src/main/java/org/opensearch/index/translog/transfer/TranslogTransferManager.java index 89a2b76e273f3..527fb0123d800 100644 --- a/server/src/main/java/org/opensearch/index/translog/transfer/TranslogTransferManager.java +++ b/server/src/main/java/org/opensearch/index/translog/transfer/TranslogTransferManager.java @@ -339,15 +339,15 @@ private void deleteFileIfExists(Path filePath) throws IOException { } } - public TranslogTransferMetadata readMetadata(long timestamp) throws IOException { - if (timestamp <= 0) { + public TranslogTransferMetadata readMetadata(long pinnedTimestamp) throws IOException { + if (pinnedTimestamp <= 0) { return readMetadata(); } return readMetadata((blobMetadataList) -> { List metadataFiles = blobMetadataList.stream().map(BlobMetadata::name).collect(Collectors.toList()); Set metadataFilesMatchingTimestamp = RemoteStoreUtils.getPinnedTimestampLockedFiles( metadataFiles, - Set.of(timestamp), + Set.of(pinnedTimestamp), file -> RemoteStoreUtils.invertLong(file.split(METADATA_SEPARATOR)[3]), TranslogTransferMetadata::getNodeIdByPrimaryTermAndGen, true