shounakmk219 commented on code in PR #16307:
URL: https://github.com/apache/pinot/pull/16307#discussion_r2207144510


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java:
##########
@@ -463,6 +473,68 @@ public SuccessResponse deleteTable(
         "Table '" + tableName + "' with type " + tableType + " does not 
exist", Response.Status.NOT_FOUND);
   }
 
+  public static void tableTasksValidation(TableConfig tableConfig,
+      PinotHelixTaskResourceManager pinotHelixTaskResourceManager) {
+    if (tableConfig.getTaskConfig() == null) {
+      return;
+    }
+    String tableWithType = tableConfig.getTableName();
+    Map<String, Map<String, String>> taskTypeConfigsMap = 
tableConfig.getTaskConfig().getTaskTypeConfigsMap();
+    for (String taskType : taskTypeConfigsMap.keySet()) {
+      Map<String, TaskState> taskStates;
+      try {
+        taskStates = 
pinotHelixTaskResourceManager.getTaskStatesByTable(taskType, tableWithType);
+      } catch (IllegalArgumentException e) {
+        LOGGER.info(e.getMessage());
+        return;
+      }
+      if (!taskStates.isEmpty()) {
+        throw new RuntimeException("The table has dangling task data, try 
performing table delete operation in case "
+            + "the delete operation was not completed successfully, else 
delete the tasks manually through "
+            + "DELETE /tasks/task/{taskName} endpoint."
+            + "Please try again once the dangling tasks are cleaned up");

Review Comment:
   makes sense, fixed it.



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