kfaraz commented on code in PR #17770: URL: https://github.com/apache/druid/pull/17770#discussion_r1977235509
########## server/src/main/java/org/apache/druid/server/coordinator/duty/KillUnusedSegments.java: ########## @@ -273,9 +273,15 @@ private Interval findIntervalForKill( ) { final DateTime minStartTime = datasourceToLastKillIntervalEnd.get(dataSource); + + // Once the first segment from a datasource is killed, we have a valid minStartTime. + // Restricting the upper bound to scan segments metadata while running the kill task results in a efficient SQL query. final DateTime maxEndTime = ignoreDurationToRetain ? DateTimes.COMPARE_DATE_AS_STRING_MAX - : DateTimes.nowUtc().minus(durationToRetain); + : DateTimes.min(DateTimes.nowUtc().minus(durationToRetain), + minStartTime != null + ? minStartTime.plus(maxIntervalToKill) + : DateTimes.nowUtc().minus(durationToRetain)); Review Comment: This is a little difficult to read. Please assign this value to a variable beforehand. -- 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...@druid.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org For additional commands, e-mail: commits-h...@druid.apache.org