dolphinscheduler icon indicating copy to clipboard operation
dolphinscheduler copied to clipboard

[Question] About Fault-tolerant design (几种任务容错情景的方案)

Open vimacro opened this issue 5 years ago • 2 comments

**For better global communication, Please describe it in English. If you feel the description in English is not clear, then you can append description in Chinese(just for Mandarin(CN)), thx! ** Describe the question

  • about fault design When Worker lost zk connection or zk crash

  • consistency of the task status

  • 关于容错设计中在zk失联或宕机恢复

  • 任务状态一致性

the task is one processInstance with one node,master hosting the processInstance,worker hosting the task

这里每个流程实例里面只有一个节点,流程实例托管在master,任务托管在worker

Which version of DolphinScheduler: -[1.3.3] -[1.3.4]

Additional context image

There are several kinds of situations to consider

有下面集中情形需要考虑

1. worker task repeat

worker节点上任务重复

image

if worker lost zk connection,master will start failover, and master1 start new task on another worker,so task1 repeat worker1 and worker2 both execute task1, if worker1 recover connection,the thread for execute is busy 如果worker节点与zk失联,master开始容错,master1 将会在另外的节点启动新的任务,worker1 和 worker2 都会执行task1 并且如果worker1 恢复zk连接,任务结束之前占用执行线程资源

possible solution:

  • when worker lost zk connection,clean local execution context, stop all task thread 可能的方案:
  • 当worker 失去zk连接的时候,清理本地执行上下文,停止所有的执行线程

2. zk crash or zk network error(like switch error)

zk 节点宕机或者zk网络失联(例如交换机故障) image

worker still executes the task

if zk recover,possible state (当zk恢复,可能出现的状态)

  • The task in TaskPriorityQueue maybe be dispatched,and other master start failover ,these task may repeat

  • Master1 received Master2 removed event, and start failover Master2(create new failover command), and Master1 start task2 ,next few ms,Master1 received Master1 removed event, and this will create new command for task2 (create new failover command),so we get multiple task1

  • 优先队列中的任务尝试去派发,但是流程实例已经在其他节点容错了,这里的任务可能重复 (zk 恢复会将节点的移除添加发送到所有的监听节点)

  • master1 收到了master2 的移除事件,开始容错master2 (创建容错command),然后master1 抢到锁,执行这个command,分配task2 执行,接下来的几毫秒,master1 收到了master1 的移除事件(也可能是其他节点收到了),这时候又创建了新的容错command,有一个master 执行这个command,因此就会导致这个节点也去派发task2 ,而且他不知道master1 已经容错了这个任务,并且master1 正在执行,只是单纯根据事件去容错 image

上面这张图仅展示了一种复现过可能出现的状态

image

When zk recovers after losing connection or recovering after multiple nodes lose connection, it will lead to similar repeated fault tolerance. Here it is necessary to decide which node needs fault tolerance and which task needs fault tolerance to prevent repeated fault tolerance.

当zk失联后恢复或者多个节点失联后恢复,会导致类似的重复容错,这里需要决策哪个节点需要容错,哪个任务需要容错,防止重复容错

3. master thread and TaskPriorityQueue clear

Master 线程与优先级清理 when master lost zk connection , Whether to clean up the execution context (MasterExecThread ,MasterTaskExecThread,TaskPriorityQueue) 当master 失联zk 的时候,是否需要清理执行上下文

vimacro avatar Jan 05 '21 09:01 vimacro

This issue has been automatically marked as stale because it has not had recent activity for 30 days. It will be closed in next 7 days if no further activity occurs.

github-actions[bot] avatar Jul 20 '24 00:07 github-actions[bot]

This issue has been closed because it has not received response for too long time. You could reopen it if you encountered similar problems in the future.

github-actions[bot] avatar Jul 28 '24 00:07 github-actions[bot]