9aman commented on code in PR #15142: URL: https://github.com/apache/pinot/pull/15142#discussion_r1973212774
########## pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/retention/RetentionManager.java: ########## @@ -136,6 +161,49 @@ private void manageRetentionForOfflineTable(String offlineTableName, RetentionSt } } + private List<String> getSegmentsToDeleteFromDeepstore(String offlineTableName, RetentionStrategy retentionStrategy, + List<String> segmentsToExclude) + throws IOException { + + List<String> segmentsToDelete = new ArrayList<>(); + String rawTableName = TableNameBuilder.extractRawTableName(offlineTableName); + URI tableDataUri = URIUtils.getUri(_pinotHelixResourceManager.getDataDir(), rawTableName); + PinotFS pinotFS = PinotFSFactory.create(tableDataUri.getScheme()); + + List<FileMetadata> deepstoreFiles = pinotFS.listFilesWithMetadata(tableDataUri, false); + + for (FileMetadata fileMetadata : deepstoreFiles) { + if (fileMetadata.isDirectory()) { + continue; + } + + String segmentName = extractSegmentName(fileMetadata.getFilePath()); + if (segmentName == null || segmentsToExclude.contains(segmentName)) { + continue; + } + + long lastModifiedTime = fileMetadata.getLastModifiedTime(); + + if (retentionStrategy.isPurgeable(segmentName, offlineTableName, lastModifiedTime)) { Review Comment: This ensures that a segment that has not entry in the ZK but has been uploaded to deepstore does not get deleted. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org