海豚调度异常处理: 使用 arthas 在内存中删除启动失败的工作流

作者 : admin 本文共1929个字,预计阅读时间需要5分钟 发布时间: 2024-06-17 共1人阅读

💡 本系列文章是 DolphinScheduler 由浅入深的教程,涵盖搭建、二开迭代、核心原理解读、运维和管理等一系列内容。适用于想对 DolphinScheduler了解或想要加深理解的读者。祝开卷有益。
大数据学习指南

大家好,我是小陶,DolphinScheduler 运行过程中会出现一些不可控的异常,可以使用 Arthas 轻松处理 JVM 中的对象,不需要重启服务。

Arthas 简单介绍

熟悉 arthas 的可以直接跳过,使用 artlas https://arthas.aliyun.com/
海豚调度异常处理: 使用 arthas 在内存中删除启动失败的工作流插图

Arthas 是一款线上监控诊断产品,通过全局视角实时查看应用 load、内存、gc、线程的状态信息,并能在不修改应用代码的情况下,对业务问题进行诊断,包括查看方法调用的出入参、异常,监测方法执行耗时,类加载信息等,大大提升线上问题排查效率。

使用 arthas 操作内存对象

这里主要用到了 vmtool + ognl 。

Master服务一直在打印错误日志,如果不处理,会给磁盘压力…
海豚调度异常处理: 使用 arthas 在内存中删除启动失败的工作流插图(1)
查看源码发现,需要处理下图这里的 startProcessFailedMap,否则会一直重试。
海豚调度异常处理: 使用 arthas 在内存中删除启动失败的工作流插图(2)

下面是使用 arthas 操作 JVM 的步骤:

①启动 arthas

java -jar arthas-boot.jar
海豚调度异常处理: 使用 arthas 在内存中删除启动失败的工作流插图(3)
输入序号,选择Master对应的进程,这里输入 2

② 查看 startProcessFailedMap 对象

查看 startProcessFailedMap,这里用到了 vmtool 这个命令

vmtool --action getInstances --className org.apache.dolphinscheduler.server.master.runner.MasterExecService --express 'instances[0].startProcessFailedMap'

输出:

@ConcurrentHashMap[
@Integer[837919]:@WorkflowExecuteThread[org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThread@14a071bc],
@Integer[938003]:@WorkflowExecuteThread[org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThread@14140a49],
]

拿着@Integer[837919]和@Integer[938003]中的数字 ID 去 MYSQL 搜一下是哪些工作流,再判断能否直接从内存中删除。

③ 删除失败的工作流

如果可以删除,继续操作,这里用到了ognl,想要了解更多的小伙伴可以看文末的参考文章。

vmtool --action getInstances --className org.apache.dolphinscheduler.server.master.runner.MasterSchedulerService --express '#map=instances[0].startProcessFailedMap,#map.remove(837919),#map'

vmtool --action getInstances --className org.apache.dolphinscheduler.server.master.runner.MasterSchedulerService --express '#map=instances[0].startProcessFailedMap,#map.remove(938003),#map'

此时,再查看

vmtool --action getInstances --className org.apache.dolphinscheduler.server.master.runner.MasterExecService --express 'instances[0].startProcessFailedMap'

输出:@ConcurrentHashMap[isEmpty=true;size=0]

错误日志没有了!

④ 数据库状态修改

最后,把数据库中这俩工作流的状态置为成功。(也就是无需处理。)

UPDATE t_ds_process_instance set state = 7 where id = xxxx

最后可以了。

Arthas 使用参考

https://www.cnblogs.com/qlqwjy/p/14269457.html

https://github.com/alibaba/arthas/issues/71


大数据学习指南
专注于大数据技术分享与交流。
海豚调度异常处理: 使用 arthas 在内存中删除启动失败的工作流插图(4)

本站无任何商业行为
个人在线分享 » 海豚调度异常处理: 使用 arthas 在内存中删除启动失败的工作流
E-->