ruanwenjun commented on code in PR #18736:
URL:
https://github.com/apache/dolphinscheduler/pull/18736#discussion_r4422229880
##########
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:
```suggestion
private boolean removeExpiredEvent(final
ReportableTaskExecutorLifecycleEventChannel eventChannel) {
...
}
```
We can loop the event from the channel, if the current time - event's
create time > event max lifecycle, then means the event is expired, we can
remove the event.
##########
dolphinscheduler-task-executor/src/main/java/org/apache/dolphinscheduler/task/executor/worker/AbstractTaskExecutorWorker.java:
##########
@@ -60,26 +60,30 @@ protected void trackTaskExecutorState(final ITaskExecutor
taskExecutor) {
protected void onTaskExecutorSuccess(final ITaskExecutor taskExecutor) {
taskExecutor.getTaskExecutionContext().setEndTime(System.currentTimeMillis());
-
taskExecutor.getTaskExecutorEventBus().publish(TaskExecutorSuccessLifecycleEvent.of(taskExecutor));
+ final TaskExecutorSuccessLifecycleEvent event =
TaskExecutorSuccessLifecycleEvent.of(taskExecutor);
onTaskExecutorFinished(taskExecutor);
+ taskExecutor.getTaskExecutorEventBus().publish(event);
}
Review Comment:
Why change the order?
##########
dolphinscheduler-task-executor/src/main/java/org/apache/dolphinscheduler/task/executor/eventbus/TaskExecutorLifecycleEventRemoteReporter.java:
##########
@@ -291,14 +317,21 @@ public static class
ReportableTaskExecutorLifecycleEventChannel {
private final
LinkedBlockingQueue<IReportableTaskExecutorLifecycleEvent>
taskExecutionEventsQueue;
- // todo: remove the master address from the channel, we need to get
the master address from the TaskExecutor
- public ReportableTaskExecutorLifecycleEventChannel(int taskExecutorId)
{
+ private volatile String workflowInstanceHost;
+
+ private volatile Long finishedTime;
Review Comment:
We don't need to add this filed, looks strange.
##########
dolphinscheduler-master/src/main/resources/application.yaml:
##########
@@ -99,6 +99,9 @@ master:
# The number of threads used to execute logic task.
# task-executor-thread-count: 10
max-heartbeat-interval: 10s
+ # Stop retrying and discard unacknowledged events after this duration from
task completion.
+ # Expiration is logged as an error; it does not mean the result was
persisted by the master.
+ task-event-report-max-duration: 1h
Review Comment:
```suggestion
task-event-report-max-duration: 6h
```
--
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]