You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2021/05/05 01:40:18 UTC

[GitHub] [druid] maytasm opened a new pull request #11200: Add feature to automatically remove supervisor based on retention period

maytasm opened a new pull request #11200:
URL: https://github.com/apache/druid/pull/11200


   Add feature to automatically remove supervisors based on retention period
   
   ### Description
   
   We currently already have tasklog auto cleanup (https://github.com/apache/druid/pull/3677) and audit logs auto cleanup (https://github.com/apache/druid/pull/11084). This PR adds a similar auto cleanup based on duration (time to retained) but for the supervisor table to auto clean up terminated supervisors
   
   This is useful when Druid user has a high churn of task / datasource in a short amount of time causing the metadata store size to grow uncontrollably. 
   
   This PR has:
   - [ ] been self-reviewed.
      - [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
   - [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.
   


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] maytasm commented on a change in pull request #11200: Add feature to automatically remove supervisor based on retention period

Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #11200:
URL: https://github.com/apache/druid/pull/11200#discussion_r627844364



##########
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:
       Done




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] abhishekagarwal87 commented on a change in pull request #11200: Add feature to automatically remove supervisor based on retention period

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] maytasm commented on a change in pull request #11200: Add feature to automatically remove supervisor based on retention period

Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #11200:
URL: https://github.com/apache/druid/pull/11200#discussion_r627844264



##########
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:
       Done




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] maytasm commented on a change in pull request #11200: Add feature to automatically remove supervisor based on retention period

Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #11200:
URL: https://github.com/apache/druid/pull/11200#discussion_r627094355



##########
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:
       The default in the code is used to fail cluster startup if the value is not set by the user. Basically code check for the value being positive (meaning that the user must set it and override the default value). For documentation simplicity sake, the default value in the code is the same effect as None and that the user must set the value. 




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] loquisgon commented on a change in pull request #11200: Add feature to automatically remove supervisor based on retention period

Posted by GitBox <gi...@apache.org>.
loquisgon commented on a change in pull request #11200:
URL: https://github.com/apache/druid/pull/11200#discussion_r626991761



##########
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:
       The code has 1S for default: PT-1s




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] loquisgon commented on a change in pull request #11200: Add feature to automatically remove supervisor based on retention period

Posted by GitBox <gi...@apache.org>.
loquisgon commented on a change in pull request #11200:
URL: https://github.com/apache/druid/pull/11200#discussion_r627678309



##########
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:
       ok, LGTM




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] maytasm commented on a change in pull request #11200: Add feature to automatically remove supervisor based on retention period

Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #11200:
URL: https://github.com/apache/druid/pull/11200#discussion_r627845174



##########
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:
       Done




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] maytasm commented on a change in pull request #11200: Add feature to automatically remove supervisor based on retention period

Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #11200:
URL: https://github.com/apache/druid/pull/11200#discussion_r627853881



##########
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:
       Done




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] maytasm merged pull request #11200: Add feature to automatically remove supervisor based on retention period

Posted by GitBox <gi...@apache.org>.
maytasm merged pull request #11200:
URL: https://github.com/apache/druid/pull/11200


   


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] maytasm commented on a change in pull request #11200: Add feature to automatically remove supervisor based on retention period

Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #11200:
URL: https://github.com/apache/druid/pull/11200#discussion_r627844675



##########
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:
       Yep. Terminated supervisor will have it's latest supervisorSpec as NoopSupervisorSpec. (Basically NoopSupervisorSpec is used as a tombstone indicator)




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] loquisgon commented on a change in pull request #11200: Add feature to automatically remove supervisor based on retention period

Posted by GitBox <gi...@apache.org>.
loquisgon commented on a change in pull request #11200:
URL: https://github.com/apache/druid/pull/11200#discussion_r626991761



##########
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:
       The code has 1S for `durationToRetain` default: PT-1s




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] maytasm commented on a change in pull request #11200: Add feature to automatically remove supervisor based on retention period

Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #11200:
URL: https://github.com/apache/druid/pull/11200#discussion_r627830277



##########
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:
       Done




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] maytasm commented on a change in pull request #11200: Add feature to automatically remove supervisor based on retention period

Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #11200:
URL: https://github.com/apache/druid/pull/11200#discussion_r627830091



##########
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:
       Done




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org