abhishekrb19 commented on code in PR #14662:
URL: https://github.com/apache/druid/pull/14662#discussion_r1275734037
##########
docs/data-management/delete.md:
##########
@@ -95,9 +95,15 @@ The available grammar is:
"id": <task_id>,
"dataSource": <task_datasource>,
"interval" : <all_unused_segments_in_this_interval_will_die!>,
- "context": <task context>
+ "context": <task context>,
+ "maxSegmentsToKill": <the maximum number of segents to delete>
Review Comment:
```suggestion
"maxSegmentsToKill": <the maximum number of segments to delete>
```
##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/KillUnusedSegmentsTask.java:
##########
@@ -78,6 +84,9 @@ public KillUnusedSegmentsTask(
context
);
this.markAsUnused = markAsUnused != null && markAsUnused;
+ Preconditions.checkArgument(maxSegmentsToKill > 0, "maxSegmentsToKill must
be > 0");
Review Comment:
I think we can `throw InvalidInput.exception()` since this should be
user-facing
##########
server/src/main/java/org/apache/druid/server/coordinator/duty/KillUnusedSegments.java:
##########
@@ -140,6 +162,12 @@ private void killUnusedSegments(Collection<String>
dataSourcesToKill)
break;
}
}
+
+ if (submittedTasks >= availableKillTaskSlots) {
+ log.info("Reached kill task slot limit with pending unused segments to
kill. Will resume "
Review Comment:
Might as well include the task slot limit and how many tasks are submitted,
something like:
```suggestion
log.info("Submitted [%d] kill tasks and reached kill task slot limit
[%d]. Will resume "
```
##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/KillUnusedSegmentsTask.java:
##########
@@ -128,6 +146,9 @@ public TaskStatus runTask(TaskToolbox toolbox) throws
Exception
}
// Kill segments
+ unusedSegments = maxSegmentsToKill == null
+ ? unusedSegments
Review Comment:
Instead of pruning out the unused segments up here, have we considered
pushing down the limit to the
[metadata](https://github.com/apache/druid/blob/master/server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataQuery.java#L119)
query so we ask only what we want? I think that should considerably reduce the
load on the metadata store, reduce the lock duration, etc, for unused segments
that aren't killed in a run anyway. What do you think?
##########
server/src/main/java/org/apache/druid/server/coordinator/CoordinatorDynamicConfig.java:
##########
@@ -158,6 +162,14 @@ public CoordinatorDynamicConfig(
this.balancerComputeThreads = Math.max(balancerComputeThreads, 1);
this.specificDataSourcesToKillUnusedSegmentsIn
= parseJsonStringOrArray(specificDataSourcesToKillUnusedSegmentsIn);
+
+ if (null != killTaskSlotRatio) {
+ Preconditions.checkArgument(
+ killTaskSlotRatio >= 0 && killTaskSlotRatio <= 1,
+ "killTaskSlotRatio must be >= 0 and <= 1"
+ );
+ }
Review Comment:
I suggest using the new Druid exception wrapper:
```suggestion
if (null != killTaskSlotRatio && (killTaskSlotRatio < 0 ||
killTaskSlotRatio > 1)) {
throw InvalidInput.exception("killTaskSlotRatio [%.2f] is invalid. It
must be >= 0 and <= 1.", killTaskSlotRatio)
}
```
##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/KillUnusedSegmentsTask.java:
##########
@@ -77,7 +83,12 @@ public KillUnusedSegmentsTask(
interval,
context
);
+ if (null != maxSegmentsToKill) {
+ Preconditions.checkArgument(maxSegmentsToKill > 0, "maxSegmentsToKill
must be > 0");
+ }
Review Comment:
Since this is user-facing, we could use `InvalidInput.exception()`:
```suggestion
if (null != maxSegmentsToKill && maxSegmentsToKill <= 0) {
throw InvalidInput.exception("maxSegmentsToKill [%d] is invalid. It
must be a positive integer.", maxSegmentsToKill);
}
```
--
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]