dolphinscheduler icon indicating copy to clipboard operation
dolphinscheduler copied to clipboard

工作流和任务实例一直显示运行,无法取消

Open moranrr opened this issue 7 years ago • 7 comments

定义了一个简单的shell任务,内容就是echo "xxxxxxxxxx"

  1. 点击工作流定义,选择一个工作流点击运行
  2. 工作流实例和任务实例都显示正在运行,而且显示一直在运行。

点击任务实例查看日志无日志输出。 点击停止,工作流实例一直都是“准备停止”,任务实例状态一直都是“正在执行”。

Mater日志:

[INFO] 2019-09-20 10:01:13.057 cn.escheduler.dao.ProcessDao:[827] - start submit task : shell-task, instance id:3526, state: RUNNING_EXEUTION, 
[ERROR] 2019-09-20 10:01:13.058 cn.escheduler.dao.ProcessDao:[1799] - cannot find the task:0 process instance
[INFO] 2019-09-20 10:01:13.058 cn.escheduler.common.queue.TaskQueueZkImpl:[99] - check task:2_3526_2_0_-1 not exist in task queue
[INFO] 2019-09-20 10:01:13.060 cn.escheduler.common.queue.TaskQueueZkImpl:[99] - check task:2_3526_2_4913_-1 not exist in task queue
[INFO] 2019-09-20 10:01:13.060 cn.escheduler.dao.ProcessDao:[1025] - task ready to queue: TaskInstance{id=4913, name='shell-task', taskType='SHELL', processDefinitionId=23, processInstanceId=3526, processInstance
Name='null', taskJson='{"depList":[],"dependence":"{}","desc":"shell 脚本","forbidden":false,"id":"tasks-53288","maxRetryTimes":0,"name":"shell-task","params":"{\"rawScript\":\"echo \\\"shell script test ! \\\"\"
,\"localParams\":[],\"resourceList\":[]}","preTasks":"[]","retryInterval":1,"runFlag":"NORMAL","taskInstancePriority":"MEDIUM","taskTimeoutParameter":{"enable":false,"interval":0},"timeout":"{\"enable\":false,\"s
trategy\":\"\"}","type":"SHELL","workerGroupId":-1}', state=SUBMITTED_SUCCESS, submitTime=Fri Sep 20 10:01:13 CST 2019, startTime=Fri Sep 20 10:01:13 CST 2019, endTime=null, host='null', executePath='null', logPa
th='null', retryTimes=0, alertFlag=NO, runFlag=null, processInstance=null, processDefine=null, pid=0, appLink='null', flag=YES, dependency=null, duration=null, maxRetryTimes=0, retryInterval=1, taskInstancePriori
ty=MEDIUM, processInstancePriority=MEDIUM, workGroupId=-1, submitUserName=qianch}
[INFO] 2019-09-20 10:01:13.063 cn.escheduler.common.queue.TaskQueueZkImpl:[126] - add task : /escheduler/tasks_queue/2_3526_2_4913_-1 to tasks queue , result success
[INFO] 2019-09-20 10:01:13.064 cn.escheduler.dao.ProcessDao:[1027] - master insert into queue success, task : shell-task
[INFO] 2019-09-20 10:01:13.064 cn.escheduler.dao.ProcessDao:[844] - submit task :shell-task state:SUBMITTED_SUCCESS complete, instance id:3526 state: RUNNING_EXEUTION  
[INFO] 2019-09-20 10:12:14.573 cn.escheduler.server.master.runner.MasterExecThread:[724] - work flow process instance [id: 3526, name:test-0-1568944872645], state change from RUNNING_EXEUTION to READY_STOP, cmd t
ype: START_PROCESS
[INFO] 2019-09-20 10:12:15.208 cn.escheduler.common.queue.TaskQueueZkImpl:[311] - add task:10.86.210.16-4913 to tasks set result:/escheduler/tasks_kill/18.96.20.16-4913 
[INFO] 2019-09-20 10:12:15.208 cn.escheduler.server.master.runner.MasterTaskExecThread:[139] - master add kill task :shell-task id:4913 to kill queue

Work 日志:

[INFO] 2019-09-20 09:54:31.147 cn.escheduler.common.queue.TaskQueueZkImpl:[340] - delete task:10.86.210.16-4912 from tasks set 
[INFO] 2019-09-20 10:01:13.464 cn.escheduler.common.queue.TaskQueueZkImpl:[212] - consume tasks: [2_3526_2_4913_-1],there still have 0 tasks need to be executed
[INFO] 2019-09-20 10:01:13.470 cn.escheduler.server.worker.runner.FetchTaskThread:[192] - worker fetch taskId : 4913 from queue 
[INFO] 2019-09-20 10:01:13.471 cn.escheduler.server.worker.runner.FetchTaskThread:[208] - task instance  local execute path : /tmp/escheduler/exec/process/11/23/3526/4913 
[INFO] 2019-09-20 10:01:13.472 cn.escheduler.server.worker.runner.FetchTaskThread:[219] - task : 4913 ready to submit to task scheduler thread
[INFO] 2019-09-20 10:01:13.472 cn.escheduler.common.queue.TaskQueueZkImpl:[279] - consume task /escheduler/tasks_queue/2_3526_2_4913_-1
[INFO] 2019-09-20 10:01:13.475 cn.escheduler.server.worker.runner.TaskScheduleThread:[102] - script path : /tmp/escheduler/exec/process/11/23/3526/4913
[INFO] 2019-09-20 10:01:16.477 cn.escheduler.common.queue.TaskQueueZkImpl:[212] - consume tasks: [],there still have 1 tasks need to be executed
[ERROR] 2019-09-20 10:12:16.718 cn.escheduler.server.utils.ProcessUtils:[258] - process kill failed, process id :0, task id:4913
[INFO] 2019-09-20 10:12:16.720 cn.escheduler.common.queue.TaskQueueZkImpl:[340] - delete task:10.86.210.16-4913 from tasks set 

moranrr avatar Sep 20 '19 02:09 moranrr

这个问题已经解决。

I fix this bug. https://github.com/apache/incubator-dolphinscheduler/pull/824

you can modify worker_logback.xml


<root level="INFO">
       <appender-ref ref="STDOUT"/> <!-- add this  -->
        <appender-ref ref="TASKLOGFILE"/>
        <appender-ref ref="WORKERLOGFILE"/>
    </root>

and check appender name is TASKLOGFILE.

 <Discriminator class="cn.escheduler.server.worker.log.TaskLogDiscriminator">
            <key>taskAppId</key>
            <logBase>${log.base}</logBase> <!-- required -->
        </Discriminator>

ww1516123 avatar Sep 20 '19 02:09 ww1516123

这个问题已经解决。

I fix this bug. #824

you can modify worker_logback.xml


<root level="INFO">
       <appender-ref ref="STDOUT"/> <!-- add this  -->
        <appender-ref ref="TASKLOGFILE"/>
        <appender-ref ref="WORKERLOGFILE"/>
    </root>

and check appender name is TASKLOGFILE.

 <Discriminator class="cn.escheduler.server.worker.log.TaskLogDiscriminator">
            <key>taskAppId</key>
            <logBase>${log.base}</logBase> <!-- required -->
        </Discriminator>

日志是如何造成任务一直显示正在运行状态并且无法取消的? 看worker的日志,好像进程ID是0,task进程一直未启动。

moranrr avatar Sep 20 '19 03:09 moranrr

class cn.escheduler.server.worker.runner.TaskScheduleThread have a method name getTaskLogPath.

 private String getTaskLogPath() {
        String baseLog = ((TaskLogDiscriminator) ((SiftingAppender) ((LoggerContext) LoggerFactory.getILoggerFactory())
                .getLogger("ROOT")
                .getAppender("TASKLOGFILE"))
                .getDiscriminator()).getLogBase();   //this line cannot get  
        if (baseLog.startsWith(Constants.SINGLE_SLASH)){
            return baseLog + Constants.SINGLE_SLASH +
                    taskInstance.getProcessDefinitionId() + Constants.SINGLE_SLASH  +
                    taskInstance.getProcessInstanceId() + Constants.SINGLE_SLASH  +
                    taskInstance.getId() + ".log";
        }
        return System.getProperty("user.dir") + Constants.SINGLE_SLASH +
                baseLog +  Constants.SINGLE_SLASH +
                taskInstance.getProcessDefinitionId() + Constants.SINGLE_SLASH  +
                taskInstance.getProcessInstanceId() + Constants.SINGLE_SLASH  +
                taskInstance.getId() + ".log";
    }

ww1516123 avatar Sep 20 '19 09:09 ww1516123

The log is not generated. It may be that the worker_logback.xml is not configured. If you use IDEA to start, please merge master_logback.xml and worker_logback.xml into logback.xml, and then start. The task is not successful, see the worker log output above: process kill failed, process id: 0, task id: 4913, process id is 0 is wrong, the process id can not be 0, this needs to be positioned

日志没有生成,可能是worker_logback.xml没有配置对,如果使用IDEA启动的,请将master_logback.xml和worker_logback.xml融合到logback.xml中,然后启动 任务没有kill成功,看你上面的worker日志输出:process kill failed, process id :0, task id:4913,process id 是 0 是不对了,进程id不能是0,这个需要定位一下

qiaozhanwei avatar Sep 23 '19 03:09 qiaozhanwei

The log is not generated. It may be that the worker_logback.xml is not configured. If you use IDEA to start, please merge master_logback.xml and worker_logback.xml into logback.xml, and then start. The task is not successful, see the worker log output above: process kill failed, process id: 0, task id: 4913, process id is 0 is wrong, the process id can not be 0, this needs to be positioned

日志没有生成,可能是worker_logback.xml没有配置对,如果使用IDEA启动的,请将master_logback.xml和worker_logback.xml融合到logback.xml中,然后启动 任务没有kill成功,看你上面的worker日志输出:process kill failed, process id :0, task id:4913,process id 是 0 是不对了,进程id不能是0,这个需要定位一下

我在想是不是日志没有生成的原因就是这个进程没有启动?process id 是0也是这个原因。 是什么原因会造成进程没有启动还不知道。

moranrr avatar Sep 23 '19 03:09 moranrr

这个问题也是偶尔会出现,后面定位过这个问题,在方法cn.escheduler.server.worker.runner.TaskScheduleThread.run()中打印日志。 发现出现问题时, logger.info("task json is : {}",taskInstance.getTaskJson()); 这行日志没有打印

logger.info("script path : {}", taskInstance.getExecutePath());
            logger.info("task json is : {}",taskInstance.getTaskJson());
            // task node
            TaskNode taskNode = JSONObject.parseObject(taskInstance.getTaskJson(), TaskNode.class);
            logger.info("get process instance according to tak instance");
            // get process instance according to tak instance
            ProcessInstance processInstance = taskInstance.getProcessInstance();
            // get process define according to tak instance
            logger.info("get process define according to tak instance");
            ProcessDefinition processDefine = taskInstance.getProcessDefine();

moranrr avatar Nov 27 '19 06:11 moranrr

Since it's already fixed, issue closed firstly, feel free to reopen it if necessary

gabry-lab avatar Jul 14 '20 09:07 gabry-lab