abhishekrb19 commented on code in PR #15673:
URL: https://github.com/apache/druid/pull/15673#discussion_r1451766136


##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/IndexerMetadataStorageAdapter.java:
##########
@@ -46,23 +47,31 @@ public IndexerMetadataStorageAdapter(
 
   public int deletePendingSegments(String dataSource, Interval deleteInterval)
   {
-    // Check the given interval overlaps the 
interval(minCreatedDateOfActiveTasks, MAX)
-    final Optional<DateTime> minCreatedDateOfActiveTasks = 
taskStorageQueryAdapter
+    // Find the earliest active task created for the specified datasource; if 
one exists,
+    // check if its interval overlaps with the delete interval.
+    final Optional<TaskInfo<Task, TaskStatus>> earliestActiveTaskStatusInfo = 
taskStorageQueryAdapter
         .getActiveTaskInfo(dataSource)
         .stream()
-        .map(TaskInfo::getCreatedTime)
-        .min(Comparator.naturalOrder());
+        .min(Comparator.comparing(TaskInfo::getCreatedTime));
 
-    final Interval activeTaskInterval = new Interval(
-        minCreatedDateOfActiveTasks.orElse(DateTimes.MAX),
-        DateTimes.MAX
-    );
+    if (earliestActiveTaskStatusInfo.isPresent()) {
+      final TaskInfo<Task, TaskStatus> theEarliestActiveTaskInfo = 
earliestActiveTaskStatusInfo.get();

Review Comment:
   yep, good suggestion!



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to