GitFireMan opened a new issue #4137:
URL: https://github.com/apache/incubator-dolphinscheduler/issues/4137
**Describe the question**
TaskPriorityQueueConsumer.run() call taskPriorityQueue.size() and if size is
0,then thread will b sleep for 1 second.
I think there is no need to do this, code is show here:
` @Override
public void run() {
List<String> failedDispatchTasks = new ArrayList<>();
while (Stopper.isRunning()) {
try {
int fetchTaskNum =
masterConfig.getMasterDispatchTaskNumber();
failedDispatchTasks.clear();
for (int i = 0; i < fetchTaskNum; i++) {
if (taskPriorityQueue.size() <= 0) {
Thread.sleep(Constants.SLEEP_TIME_MILLIS);
continue;
}
// if not task , blocking here
String taskPriorityInfo = taskPriorityQueue.take();
TaskPriority taskPriority =
TaskPriority.of(taskPriorityInfo);
boolean dispatchResult =
dispatch(taskPriority.getTaskId());
if (!dispatchResult) {
failedDispatchTasks.add(taskPriorityInfo);
}
}
for (String dispatchFailedTask : failedDispatchTasks) {
taskPriorityQueue.put(dispatchFailedTask);
}
} catch (Exception e) {
logger.error("dispatcher task error", e);
}
}
}`
I think these three lines removed will be better.
` if (taskPriorityQueue.size() <= 0) {
Thread.sleep(Constants.SLEEP_TIME_MILLIS);
continue;
}`
----------------------------------------------------------------
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]