private void deleteFromMemory(String taskId) {
        Task oldTask = taskMap.get(taskId);
        if (oldTask == null) {
            LOGGER.error("old task {} not found", taskId);
            return;
        }
        oldTask.destroy();
        taskMap.remove(oldTask.getTaskId());
        LOGGER.info(
                "delete task {} from memory, taskMap size {}, runningPool task total {}, runningPool task active {}",
                oldTask.getTaskId(), taskMap.size(), runningPool.getTaskCount(),
                runningPool.getActiveCount());
    }
add task to memory, if there is a record refer to the task id exist we need to destroy it first.
inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/task/TaskManager.java