snleee commented on a change in pull request #5828:
URL: https://github.com/apache/incubator-pinot/pull/5828#discussion_r467352941



##########
File path: 
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/retention/RetentionManager.java
##########
@@ -177,4 +193,87 @@ private boolean shouldDeleteInProgressLLCSegment(String 
segmentName, IdealState
       return states.size() == 1 && 
states.contains(CommonConstants.Helix.StateModel.SegmentStateModel.OFFLINE);
     }
   }
+
+  private void manageSegmentLineageCleanupForTable(String tableNameWithType) {
+    try {
+      DEFAULT_RETRY_POLICY.attempt(() -> {
+        // Fetch segment lineage
+        ZNRecord segmentLineageZNRecord = SegmentLineageAccessHelper
+            
.getSegmentLineageZNRecord(_pinotHelixResourceManager.getPropertyStore(), 
tableNameWithType);
+        if (segmentLineageZNRecord == null) {
+          LOGGER.info("Segment lineage does not exist for table: {}", 
tableNameWithType);
+          return true;
+        }
+        SegmentLineage segmentLineage = 
SegmentLineage.fromZNRecord(segmentLineageZNRecord);
+        int expectedVersion = segmentLineageZNRecord.getVersion();
+
+        // Delete segments based on the segment lineage
+        PinotResourceManagerResponse response = _pinotHelixResourceManager
+            .deleteSegments(tableNameWithType, 
computeSegmentsToDeleteFromSegmentLineage(segmentLineage));
+
+        Assert.assertTrue(response.isSuccessful());

Review comment:
       Good catch. I was writing a testing code right before I wrote this part 
:) 




----------------------------------------------------------------
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.

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

Reply via email to