gianm commented on a change in pull request #6206: Fix NPE in 
KafkaSupervisor.checkpointTaskGroup
URL: https://github.com/apache/incubator-druid/pull/6206#discussion_r212811973
 
 

 ##########
 File path: 
extensions-core/kafka-indexing-service/src/main/java/io/druid/indexing/kafka/supervisor/KafkaSupervisor.java
 ##########
 @@ -1480,31 +1506,38 @@ private void checkTaskDuration() throws 
InterruptedException, ExecutionException
         String taskId = taskEntry.getKey();
         TaskData task = taskEntry.getValue();
 
-        if (task.status.isSuccess()) {
-          // If any task in this group has already completed, stop the rest of 
the tasks in the group and return.
-          // This will cause us to create a new set of tasks next cycle that 
will start from the offsets in
-          // metadata store (which will have advanced if we succeeded in 
publishing and will remain the same if publishing
-          // failed and we need to re-ingest)
-          return Futures.transform(
-              stopTasksInGroup(taskGroup),
-              new Function<Object, Map<Integer, Long>>()
-              {
-                @Nullable
-                @Override
-                public Map<Integer, Long> apply(@Nullable Object input)
+        // task.status can be null if any runNotice is processed before 
kafkaSupervisor is stopped gracefully.
+        if (task.status != null) {
+          if (task.status.isSuccess()) {
+            // If any task in this group has already completed, stop the rest 
of the tasks in the group and return.
+            // This will cause us to create a new set of tasks next cycle that 
will start from the offsets in
+            // metadata store (which will have advanced if we succeeded in 
publishing and will remain the same if
+            // publishing failed and we need to re-ingest)
+            return Futures.transform(
+                stopTasksInGroup(taskGroup),
+                new Function<Object, Map<Integer, Long>>()
                 {
-                  return null;
+                  @Nullable
+                  @Override
+                  public Map<Integer, Long> apply(@Nullable Object input)
+                  {
+                    return null;
+                  }
                 }
-              }
-          );
-        }
+            );
+          }
 
-        if (task.status.isRunnable()) {
-          if 
(taskInfoProvider.getTaskLocation(taskId).equals(TaskLocation.unknown())) {
-            log.info("Killing task [%s] which hasn't been assigned to a 
worker", taskId);
-            killTask(taskId);
-            i.remove();
+          if (task.status.isRunnable()) {
+            if 
(taskInfoProvider.getTaskLocation(taskId).equals(TaskLocation.unknown())) {
+              log.info("Killing task [%s] which hasn't been assigned to a 
worker", taskId);
+              killTask(taskId);
+              i.remove();
+            }
           }
+        } else {
+          log.info("Killing task [%s] of unknown status", taskId);
 
 Review comment:
   I read the code more closely and now I see that the idea is that at 
`taskDuration`, tasks should do a final publish and exit. So that's what 
`finalize` is for. The checkpointTaskGroup function, when finalize is true, 
will check if any task completed, and if so, stop all its replicas. This makes 
sense, since there is no point in replicas continuing to run if some task in 
the group is done. (Because they are all doing the same work.)
   
   With your patch, checkpointTaskGroup, when finalize is true, will now kill 
any task that has null status. I don't see why this is a good thing. After the 
`taskDuration` is over, we want to trigger a final checkpoint/publish, and then 
let all tasks in a group keep running until one of them is successful. Killing 
one with unknown status seems counter-productive to that goal.
   
   Am I wrong -- is there a reason it's a good idea to kill tasks with unknown 
status in this case?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to