csurong commented on code in PR #18736:
URL: 
https://github.com/apache/dolphinscheduler/pull/18736#discussion_r4537219356


##########
dolphinscheduler-task-executor/src/main/java/org/apache/dolphinscheduler/task/executor/eventbus/TaskExecutorLifecycleEventRemoteReporter.java:
##########
@@ -179,13 +191,22 @@ public Map<Integer, 
ReportableTaskExecutorLifecycleEventChannel> getEventChannel
         return eventChannels;
     }
 
-    private void finalizeTaskExecutor(final Integer taskExecutorId) {
-        final Optional<ITaskExecutor> taskExecutorOptional = 
taskExecutorRepository.get(taskExecutorId);
-        if (taskExecutorOptional.isPresent()) {
-            taskExecutorOptional.get().getTaskExecutorEventBus()
-                    
.publish(TaskExecutorFinalizeLifecycleEvent.of(taskExecutorOptional.get()));
-        } else {
-            log.warn("TaskExecutor is not exists: {}", taskExecutorId);
+    private boolean expireFinishedTaskEventChannel(final 
ReportableTaskExecutorLifecycleEventChannel eventChannel) {
+        eventChannelsLock.lock();
+        try {
+            if (eventChannel.finishedTime == null
+                    || System.currentTimeMillis() - eventChannel.finishedTime 
< taskEventReportMaxDurationMillis) {
+                return false;
+            }
+            if (eventChannels.remove(eventChannel.getTaskExecutorId(), 
eventChannel)) {
+                log.error("Task executor {} result was not acknowledged within 
{} ms after completion. "
+                        + "Discarding pending events for master {}",
+                        eventChannel.getTaskExecutorId(), 
taskEventReportMaxDurationMillis,
+                        eventChannel.workflowInstanceHost);
+            }
+            return true;
+        } finally {
+            eventChannelsLock.unlock();
         }
     }

Review Comment:
   Thanks @ruanwenjun. The current version already uses the event creation time 
and no longer stores `finishedTime`.
   
   I kept channel-level cleanup because earlier events can be prerequisites: if 
`DISPATCHED` expires and is removed first, the Master can ignore the following 
`SUCCESS` while still ACKing it. There’s an integration test covering this 
sequence, so the current code retains those events until the terminal event 
expires.
   
   Would you prefer a simpler implementation of this channel-level cleanup, or 
do you still suggest expiring each event independently? I want to make sure I 
understand the change you’re asking for.



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

Reply via email to