abhishekagarwal87 commented on a change in pull request #11200:
URL: https://github.com/apache/druid/pull/11200#discussion_r627285722
##########
File path:
server/src/main/java/org/apache/druid/metadata/MetadataSupervisorManager.java
##########
@@ -34,4 +34,12 @@
Map<String, List<VersionedSupervisorSpec>> getAll();
Map<String, SupervisorSpec> getLatest();
+
+ /**
+ * Remove terminated supervisor created older than the given timestamp.
Review comment:
```suggestion
* Remove terminated supervisors created before the given timestamp.
```
##########
File path: docs/configuration/index.md
##########
@@ -747,6 +747,9 @@ These Coordinator static configurations can be defined in
the `coordinator/runti
|Property|Description|Required?|Default|
|--------|-----------|---------|-------|
|`druid.coordinator.period.metadataStoreManagementPeriod`|How often to run
metadata management tasks in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)
duration format. |No | `PT1H`|
+|`druid.coordinator.kill.supervisor.on`| Boolean value for whether to enable
automatic deletion of terminated supervisors. If set to true, Coordinator will
periodically remove terminated supervisors from the supervisor table in
metadata storage.| No | False|
+|`druid.coordinator.kill.supervisor.period`| How often to do automatic
deletion of terminated supervisor in [ISO
8601](https://en.wikipedia.org/wiki/ISO_8601) duration format. Value must be
greater than `druid.coordinator.period.metadataStoreManagementPeriod`. Only
applies if `druid.coordinator.kill.supervisor.on` is set to True.| No| `P1D`|
Review comment:
```suggestion
|`druid.coordinator.kill.supervisor.period`| How often to do automatic
deletion of terminated supervisor in [ISO
8601](https://en.wikipedia.org/wiki/ISO_8601) duration format. Value must be
equal to or greater than
`druid.coordinator.period.metadataStoreManagementPeriod`. Only applies if
`druid.coordinator.kill.supervisor.on` is set to "True".| No| `P1D`|
```
##########
File path: docs/configuration/index.md
##########
@@ -747,6 +747,9 @@ These Coordinator static configurations can be defined in
the `coordinator/runti
|Property|Description|Required?|Default|
|--------|-----------|---------|-------|
|`druid.coordinator.period.metadataStoreManagementPeriod`|How often to run
metadata management tasks in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)
duration format. |No | `PT1H`|
+|`druid.coordinator.kill.supervisor.on`| Boolean value for whether to enable
automatic deletion of terminated supervisors. If set to true, Coordinator will
periodically remove terminated supervisors from the supervisor table in
metadata storage.| No | False|
+|`druid.coordinator.kill.supervisor.period`| How often to do automatic
deletion of terminated supervisor in [ISO
8601](https://en.wikipedia.org/wiki/ISO_8601) duration format. Value must be
greater than `druid.coordinator.period.metadataStoreManagementPeriod`. Only
applies if `druid.coordinator.kill.supervisor.on` is set to True.| No| `P1D`|
+|`druid.coordinator.kill.supervisor.durationToRetain`| Duration of terminated
supervisor to be retained from created time in [ISO
8601](https://en.wikipedia.org/wiki/ISO_8601) duration format. Only applies if
`druid.coordinator.kill.supervisor.on` is set to True.| Yes if
`druid.coordinator.kill.supervisor.on` is set to True| None|
Review comment:
```suggestion
|`druid.coordinator.kill.supervisor.durationToRetain`| Duration of
terminated supervisor to be retained from created time in [ISO
8601](https://en.wikipedia.org/wiki/ISO_8601) duration format. Only applies if
`druid.coordinator.kill.supervisor.on` is set to "True".| Yes if
`druid.coordinator.kill.supervisor.on` is set to "True"| None|
```
##########
File path:
server/src/main/java/org/apache/druid/metadata/SQLMetadataSupervisorManager.java
##########
@@ -249,6 +252,34 @@ public Void withHandle(Handle handle) throws Exception
);
}
+ @Override
+ public int removeTerminatedSupervisorsOlderThan(long timestamp)
+ {
+ int removedCount = 0;
+ DateTime dateTime = DateTimes.utc(timestamp);
+ Map<String, SupervisorSpec> supervisors = getLatest();
+ for (Map.Entry<String, SupervisorSpec> supervisor :
supervisors.entrySet()) {
+ final SupervisorSpec spec = supervisor.getValue();
+ if (spec instanceof NoopSupervisorSpec) {
Review comment:
does this mean that it is a terminated supervisor? can you add a comment
clarifying this bit
##########
File path:
server/src/main/java/org/apache/druid/server/coordinator/duty/KillSupervisors.java
##########
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server.coordinator.duty;
+
+import com.google.common.base.Preconditions;
+import com.google.inject.Inject;
+import org.apache.druid.java.util.common.logger.Logger;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceMetricEvent;
+import org.apache.druid.metadata.MetadataSupervisorManager;
+import org.apache.druid.server.coordinator.DruidCoordinatorConfig;
+import org.apache.druid.server.coordinator.DruidCoordinatorRuntimeParams;
+
+public class KillSupervisors implements CoordinatorDuty
Review comment:
javadocs
##########
File path: docs/operations/metrics.md
##########
@@ -256,6 +256,7 @@ These metrics are for the Druid Coordinator and are reset
each time the Coordina
|`interval/skipCompact/count`|Total number of intervals of this datasource
that are skipped (not eligible for auto compaction) by the auto
compaction.|datasource.|Varies.|
|`coordinator/time`|Approximate Coordinator duty runtime in milliseconds. The
duty dimension is the string alias of the Duty that is being run.|duty.|Varies.|
|`coordinator/global/time`|Approximate runtime of a full coordination cycle in
milliseconds. The `dutyGroup` dimension indicates what type of coordination
this run was. i.e. Historical Management vs Indexing|`dutyGroup`|Varies.|
+|`metadata/kill/supervisor/count`|Total number of terminated supervisors
automatically deleted from metadata store supervisor table per each Coordinator
kill supervisor duty run. This metric can help adjust
`druid.coordinator.kill.supervisor.durationToRetain` configuration based on if
more or less terminated supervisors need to be deleted per cycle. Note that
this metric is only emitted when `druid.coordinator.kill.supervisor.on` is set
to true.| |Varies.|
Review comment:
```suggestion
|`metadata/kill/supervisor/count`|Total number of terminated supervisors
that were automatically deleted from metadata store per each Coordinator kill
supervisor duty run. This metric can help adjust
`druid.coordinator.kill.supervisor.durationToRetain` configuration based on
whether more or less terminated supervisors need to be deleted per cycle. Note
that this metric is only emitted when `druid.coordinator.kill.supervisor.on` is
set to true.| |Varies.|
```
##########
File path:
server/src/main/java/org/apache/druid/metadata/SQLMetadataSupervisorManager.java
##########
@@ -249,6 +252,34 @@ public Void withHandle(Handle handle) throws Exception
);
}
+ @Override
+ public int removeTerminatedSupervisorsOlderThan(long timestamp)
+ {
+ int removedCount = 0;
+ DateTime dateTime = DateTimes.utc(timestamp);
+ Map<String, SupervisorSpec> supervisors = getLatest();
+ for (Map.Entry<String, SupervisorSpec> supervisor :
supervisors.entrySet()) {
+ final SupervisorSpec spec = supervisor.getValue();
+ if (spec instanceof NoopSupervisorSpec) {
+ removedCount += dbi.withHandle(
+ handle -> {
+ Update sql = handle.createStatement(
+ StringUtils.format(
+ "DELETE FROM %1$s WHERE spec_id = :spec_id AND
created_date < :date_time",
Review comment:
does it make sense to delete in batch than doing one by one which will
be slow?
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]