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


##########
server/src/main/java/org/apache/druid/server/coordinator/duty/KillUnusedSegments.java:
##########
@@ -141,18 +162,24 @@ private DruidCoordinatorRuntimeParams runInternal(final 
DruidCoordinatorRuntimeP
     final CoordinatorRunStats stats = params.getCoordinatorStats();
 
     final int availableKillTaskSlots = 
getAvailableKillTaskSlots(dynamicConfig, stats);
-    Collection<String> dataSourcesToKill = 
dynamicConfig.getSpecificDataSourcesToKillUnusedSegmentsIn();
-
-    if (availableKillTaskSlots > 0) {
-      // If no datasource has been specified, all are eligible for killing 
unused segments
-      if (CollectionUtils.isNullOrEmpty(dataSourcesToKill)) {
-        dataSourcesToKill = 
segmentsMetadataManager.retrieveAllDataSourceNames();
-      }
+    if (availableKillTaskSlots <= 0) {
+      log.info("Skipping KillUnusedSegments because there are no available 
kill task slots.");
+      return params;
+    }
 
-      lastKillTime = DateTimes.nowUtc();
-      killUnusedSegments(dataSourcesToKill, availableKillTaskSlots, stats);
+    final Set<String> dataSourcesToKill;
+    if 
(!CollectionUtils.isNullOrEmpty(dynamicConfig.getSpecificDataSourcesToKillUnusedSegmentsIn()))
 {
+      dataSourcesToKill = 
dynamicConfig.getSpecificDataSourcesToKillUnusedSegmentsIn();
+    } else {
+      // If no datasource has been specified, all are eligible for killing 
unused segments by default
+      dataSourcesToKill = segmentsMetadataManager.retrieveAllDataSourceNames();
     }
 
+    datasourceIterator.updateCandidates(dataSourcesToKill);

Review Comment:
   >So this means that on every autoKill run cycle, we are affectively taking a 
new random start to the datasources to kill list, and working from there, 
right? If so, I think this is good.
   
   Yeah, exactly. If the datasources haven't changed, the iteration just 
resumes from the last position.
   
   > Also, if this is being updated each time, why keep the state at class 
level, instead of just having local variable that we use each time we go to 
kill unused segments. That way we dont have to worry about thread safety
   
   The cursor needs to be stateful as we reset it only when the candidates have 
changed when `updateCandidates()` is called. If we want thread-safety, we can 
perhaps address that separately using synchronization primitives. But right 
now, thread safety is not a requirement, since the usage of the iterator in the 
kill duty is guaranteed to be thread-safe.



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