yangyichao-mango commented on a change in pull request #3427:
URL:
https://github.com/apache/incubator-dolphinscheduler/pull/3427#discussion_r470930298
##########
File path:
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskExecuteThread.java
##########
@@ -256,4 +275,59 @@ private void downloadResource(String execLocalPath,
}
}
}
+
+ /**
+ * delay execution if needed
+ */
+ private void delayExecutionIfNeeded() {
+ long remainTime =
DateUtils.getRemainTime(taskExecutionContext.getFirstSubmitTime(),
+ taskExecutionContext.getDelayTime() * 60L);
+ logger.info("delay execution time: {} s", remainTime < 0 ? 0 :
remainTime);
+ if (remainTime > 0) {
+ try {
+ Thread.sleep(remainTime * Constants.SLEEP_TIME_MILLIS);
Review comment:
Hi,
After this PR is merged, we can further talk about the optimize of the
delayed task execution. The current implementation method is `Thread.sleep()`。
I personally understand that many scenarios that need to use delay should be
tens of minutes or several hours. In this scenario, task threads will be
occupied all the time and will not be released, which will consume a lot of
resources. After this PR is merged, we can talk about the optimization. For
example, we can put the delayed tasks into a deferred execution pool and have a
separate thread to scan whether they can be executed, and take out the tasks to
be executed.
---------------
等这个pr合了之后,我们可以再讨论下把延迟的任务执行优化下,现在的实现方式是`Thread.sleep()`。
我个人理解,很多需要用到延迟的场景应该都是几十分钟或者几个小时的延迟,这种场景下任务线程会一直被占用,得不到释放,会对资源消耗很大。之后可以讨论下是不是可以把延迟执行的任务放在一个延迟执行池里,单独有一个线程去扫描是否可以执行,将需要执行的任务拿出来进行执行。
If you have any suggestions or questions, welcome to put forward~
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]