jtuglu1 commented on code in PR #18851:
URL: https://github.com/apache/druid/pull/18851#discussion_r2639536999


##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/hrtr/HttpRemoteTaskRunner.java:
##########
@@ -466,60 +377,82 @@ private boolean runTaskOnWorker(
   // because that is attached by TaskQueue to task result future. So, this 
method must not be called with "statusLock"
   // held. See https://github.com/apache/druid/issues/6201
   private void taskComplete(
-      HttpRemoteTaskRunnerWorkItem taskRunnerWorkItem,
-      WorkerHolder workerHolder,
+      String taskId,
+      String workerHost,
       TaskStatus taskStatus
   )
   {
-    Preconditions.checkState(!Thread.holdsLock(statusLock), "Current thread 
must not hold statusLock.");
-    Preconditions.checkNotNull(taskRunnerWorkItem, "taskRunnerWorkItem");
-    Preconditions.checkNotNull(taskStatus, "taskStatus");
-    if (workerHolder != null) {
-      log.info(
-          "Worker[%s] completed task[%s] with status[%s]",
-          workerHolder.getWorker().getHost(),
-          taskStatus.getId(),
-          taskStatus.getStatusCode()
-      );
-      // Worker is done with this task
-      workerHolder.setLastCompletedTaskTime(DateTimes.nowUtc());
-    }
+    Preconditions.checkState(!Thread.holdsLock(workerStateLock), "Current 
thread must not hold workerStateLock.");
+    Preconditions.checkState(!Thread.holdsLock(taskStateLock), "Current thread 
must not hold taskStateLock.");
 
-    if (taskRunnerWorkItem.getResult().isDone()) {
-      // This is not the first complete event.
-      try {
-        TaskState lastKnownState = 
taskRunnerWorkItem.getResult().get().getStatusCode();
-        if (taskStatus.getStatusCode() != lastKnownState) {
-          log.warn(
-              "The state of the new task complete event is different from its 
last known state. "
-              + "New state[%s], last known state[%s]",
-              taskStatus.getStatusCode(),
-              lastKnownState
-          );
+    AtomicBoolean taskCompleted = new AtomicBoolean(false);
+
+    tasks.compute(
+        taskId,
+        (key, taskEntry) -> {
+          Preconditions.checkState(taskEntry != null, "Expected task[%s] to 
exist", taskId);
+          if (taskEntry.getResult().isDone()) {
+            // This is not the first complete event.
+            try {
+              TaskState lastKnownState = 
taskEntry.getResult().get().getStatusCode();
+              if (taskStatus.getStatusCode() != lastKnownState) {
+                log.warn(
+                    "The state of the new task complete event is different 
from its last known state. "
+                    + "New state[%s], last known state[%s]",
+                    taskStatus.getStatusCode(),
+                    lastKnownState
+                );
+              }
+            }
+            catch (InterruptedException e) {
+              log.warn(e, "Interrupted while getting the last known task 
status.");
+              Thread.currentThread().interrupt();
+            }
+            catch (ExecutionException e) {
+              // This case should not really happen.
+              log.warn(e, "Failed to get the last known task status. Ignoring 
this failure.");
+            }
+          } else {
+            // Notify interested parties

Review Comment:
   Ah – I think that's a stale comment. See 
[here](https://github.com/apache/druid/blob/f1b210a55425459861bccccb4233d21c56e5aaba/indexing-service/src/main/java/org/apache/druid/indexing/overlord/hrtr/HttpRemoteTaskRunner.java#L455)
 – I just moved this down.



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