Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -606,22 +606,14 @@ private static void taskReport(long backendId, Map<TTaskType, Set<Long>> running
AgentBatchTask batchTask = new AgentBatchTask(Config.report_resend_batch_task_num_per_rpc);
long taskReportTime = System.currentTimeMillis();
for (AgentTask task : diffTasks) {
// these tasks no need to do diff
// 1. CREATE
// 2. SYNC DELETE
// 3. CHECK_CONSISTENCY
// 4. STORAGE_MDEIUM_MIGRATE
if (task.getTaskType() == TTaskType.CREATE
|| task.getTaskType() == TTaskType.CHECK_CONSISTENCY
|| task.getTaskType() == TTaskType.STORAGE_MEDIUM_MIGRATE) {
if (!task.isNeedResendType()) {
continue;
}

// to escape sending duplicate agent task to be
if (task.shouldResend(taskReportTime)) {
batchTask.addTask(task);
}

}

if (LOG.isDebugEnabled()) {
Expand Down
11 changes: 11 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/task/AgentTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,17 @@ public boolean isFinished() {
return isFinished;
}

public boolean isNeedResendType() {
// these tasks no need to do diff
// 1. CREATE
// 2. SYNC DELETE
// 3. CHECK_CONSISTENCY
// 4. STORAGE_MEDIUM_MIGRATE
return !(taskType == TTaskType.CREATE
|| taskType == TTaskType.CHECK_CONSISTENCY
|| taskType == TTaskType.STORAGE_MEDIUM_MIGRATE);
}

public boolean shouldResend(long currentTimeMillis) {
return createTime == -1 || currentTimeMillis - createTime > Config.agent_task_resend_wait_time_ms;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,34 @@
import org.apache.doris.common.ThreadPoolManager;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;

public class AgentTaskExecutor {

private static final ExecutorService EXECUTOR = ThreadPoolManager.newDaemonCacheThreadPool(
private static final ExecutorService EXECUTOR = ThreadPoolManager.newDaemonCacheThreadPoolThrowException(
Config.max_agent_task_threads_num, "agent-task-pool", true);

public AgentTaskExecutor() {

}

public static void submit(AgentBatchTask task) {
if (task == null) {
return;
}
EXECUTOR.submit(task);
try {
EXECUTOR.submit(task);
} catch (RejectedExecutionException e) {
String msg = "Task is rejected, because the agent-task-pool is full, "
+ "consider increasing the max_agent_task_threads_num config";
for (AgentTask t : task.getAllTasks()) {
// Skip the task if it is a resend type and already exists in the queue, because it will be
// re-submit to the executor later.
if (t.isNeedResendType() && AgentTaskQueue.contains(t)) {
continue;
}
t.failedWithMsg(msg);
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,19 @@ public static synchronized void removeTaskOfType(TTaskType type, long signature)
}
}

public static synchronized boolean contains(AgentTask task) {
long backendId = task.getBackendId();
TTaskType type = task.getTaskType();
long signature = task.getSignature();

if (!tasks.contains(backendId, type)) {
return false;
}

Map<Long, AgentTask> signatureMap = tasks.get(backendId, type);
return signatureMap.containsKey(signature);
}

public static synchronized AgentTask getTask(long backendId, TTaskType type, long signature) {
if (!tasks.contains(backendId, type)) {
return null;
Expand Down