snleee commented on a change in pull request #7744: URL: https://github.com/apache/pinot/pull/7744#discussion_r747781630
########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java ########## @@ -2784,32 +2786,55 @@ public String startReplaceSegments(String tableNameWithType, List<String> segmen Preconditions.checkArgument(segmentLineage.getLineageEntry(segmentLineageEntryId) == null, String.format("SegmentLineageEntryId (%s) already exists in the segment lineage.", segmentLineageEntryId)); + List<String> segmentsToCleanUp = new ArrayList<>(); for (String entryId : segmentLineage.getLineageEntryIds()) { LineageEntry lineageEntry = segmentLineage.getLineageEntry(entryId); - // If segment entry is in 'REVERTED' state, no need to check for 'segmentsFrom'. - if (lineageEntry.getState() != LineageEntryState.REVERTED) { + // If the lineage entry is in 'REVERTED' state, no need to go through the validation because we can regard + // the entry as not existing. + if (lineageEntry.getState() == LineageEntryState.REVERTED) { + continue; + } + + // By here, the lineage entry is either 'IN_PROGRESS' or 'COMPLETED'. + if (forceCleanup && lineageEntry.getState() == LineageEntryState.IN_PROGRESS && CollectionUtils + .isEqualCollection(segmentsFrom, lineageEntry.getSegmentsFrom())) { + // When 'forceCleanup' is enabled, we need to proactively revert the lineage entry when we find the lineage + // entry with the same 'segmentFrom' values. + segmentLineage.updateLineageEntry(entryId, Review comment: Good point! I added a function for `updateSegmentLineageEntryToReverted()` and reuse the same function from both `startReplaceSegments` and `revertReplaceSegments`. Can you double check on the logic? -- 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