WangJPLeo commented on code in PR #11464:
URL: https://github.com/apache/dolphinscheduler/pull/11464#discussion_r945147262
##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumer.java:
##########
@@ -176,6 +203,41 @@ public List<TaskPriority> batchDispatch(int fetchTaskNum)
throws TaskPriorityQue
return failedDispatchTasks;
}
+ /**
+ * put the failed dispatch task into the dispatch queue again
+ */
+ private void dispatchFailedBackToTaskPriorityQueue(int fetchTaskNum)
throws TaskPriorityQueueException, InterruptedException {
+ try {
+ for (int i = 0; i < fetchTaskNum; i++) {
+ TaskPriority dispatchFailedTaskPriority =
taskPriorityDispatchFailedQueue.poll(Constants.SLEEP_TIME_MILLIS,
TimeUnit.MILLISECONDS);
+ if (Objects.isNull(dispatchFailedTaskPriority)){
+ continue;
+ }
+ if (canRetry(dispatchFailedTaskPriority)){
+
dispatchFailedTaskPriority.setDispatchFailedRetryTimes(dispatchFailedTaskPriority.getDispatchFailedRetryTimes()
+ 1);
+ taskPriorityQueue.put(dispatchFailedTaskPriority);
+ } else {
+
taskPriorityDispatchFailedQueue.put(dispatchFailedTaskPriority);
+ }
+ }
+ } catch (Exception e) {
+ logger.error("dispatch failed back to task priority queue error",
e);
+ }
+ }
+
+ /**
+ * the time interval is adjusted according to the number of retries
+ */
+ private boolean canRetry (TaskPriority taskPriority){
+ int dispatchFailedRetryTimes =
taskPriority.getDispatchFailedRetryTimes();
+ long now = System.currentTimeMillis();
+ // retry more than 100 times with 100 seconds delay each time
+ if (dispatchFailedRetryTimes >= Constants.DEFAULT_MAX_RETRY_COUNT){
+ return now - taskPriority.getLastDispatchTime() >=
TIME_DELAY[Constants.DEFAULT_MAX_RETRY_COUNT];
Review Comment:
Forgot to initialize the start value, thanks a lot.
--
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]