xuxueli / xxl-job

A distributed task scheduling framework.(分布式任务调度平台XXL-JOB)
http://www.xuxueli.com/xxl-job/
GNU General Public License v3.0
27.46k stars 10.86k forks source link

优雅停机大概率出现,优雅中断线程后,状态没有同步到admin #1103

Closed WEIZIBIN closed 4 years ago

WEIZIBIN commented 5 years ago

Please answer some questions before submitting your issue. Thanks!

Which version of XXL-JOB do you using?

目前在master、2.1.0版本都验证了此问题

Expected behavior

graceful shutdown 调起 XxlJobExcutor destroy 方法 所有任务线程执行结果推到admin后再关闭回调线程

Actual behavior

JobThread大概率在TriggerCallbackThread销毁后,才添加失败消息到TriggerCallbackThread队列中,导致执行结果丢失

23:12:11.919 logback [xxl-job, executor TriggerCallbackThread] INFO  c.x.j.c.thread.TriggerCallbackThread - after stop callback queue size 0
23:12:11.919 logback [xxl-job, executor TriggerCallbackThread] INFO  c.x.j.c.thread.TriggerCallbackThread - after last callback queue size 0
23:12:11.920 logback [xxl-job, executor TriggerCallbackThread] INFO  c.x.j.c.thread.TriggerCallbackThread - >>>>>>>>>>> xxl-job, executor callback thread destory.
23:12:11.920 logback [Thread-8] INFO  c.x.j.c.thread.TriggerCallbackThread - >>>>>>>>>>> xxl-job, executor retry callback thread destory.
23:12:11.921 logback [Thread-9] INFO  com.xxl.rpc.remoting.net.Server - >>>>>>>>>>> xxl-rpc remoting server stop.
23:12:11.922 logback [Thread-19] INFO  c.x.j.c.thread.TriggerCallbackThread - >>>>>>>>>>> callback queue items [HandleCallbackParam{logId=2789, logDateTim=1567091528922, executeResult=ReturnT [code=500, msg=web container destroy and kill the job. [job running,killed], content=null]}]

admin截图

Steps to reproduce the behavior

分支:https://github.com/WEIZIBIN/xxl-job/tree/issue_graceful_shutdown_callback_lose

添加了容器优雅停机,线程回调前后的日志

1.启动xxl-job-admin 2.启动xxl-job-executor-sample-springboot 3.手动触发DemoJobHandler任务执行 4.在执行过程中,优雅中止xxl-job-executor-sample-springboot进程

进程停止后,该任务大概率处于执行中的状态

Other information

xiaoluobotouzi commented 4 years ago

有结论吗??我也模拟了这样的情况。任务处于运行状态

WEIZIBIN commented 4 years ago

有结论吗??我也模拟了这样的情况。任务处于运行状态

目前版本是有这种情况,解决方案可以参考我的MR https://github.com/xuxueli/xxl-job/pull/1104