From db7fdf194abb917c3e15aab55625dc75269fd963 Mon Sep 17 00:00:00 2001 From: xuxueli <931591021@qq.com> Date: Thu, 25 Jul 2019 17:13:54 +0800 Subject: [PATCH] =?UTF-8?q?DB=E9=87=8D=E8=BF=9E=E4=BC=98=E5=8C=96=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DDB=E5=AE=95=E6=9C=BA=E9=87=8D=E8=BF=9E?= =?UTF-8?q?=E5=90=8E=E4=BB=BB=E5=8A=A1=E8=B0=83=E5=BA=A6=E5=81=9C=E6=AD=A2?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=E9=87=8D=E8=BF=9E=E5=90=8E?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8A=A0=E5=85=A5=E8=B0=83=E5=BA=A6=E9=9B=86?= =?UTF-8?q?=E7=BE=A4=E8=A7=A6=E5=8F=91=E4=BB=BB=E5=8A=A1=E8=B0=83=E5=BA=A6?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/XXL-JOB官方文档.md | 11 ++--- .../admin/core/thread/JobScheduleHelper.java | 44 ++++++++++++------- .../resources/static/js/jobinfo.index.1.js | 4 +- 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/doc/XXL-JOB官方文档.md b/doc/XXL-JOB官方文档.md index d2cc40d1..096590bf 100644 --- a/doc/XXL-JOB官方文档.md +++ b/doc/XXL-JOB官方文档.md @@ -1516,11 +1516,12 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段 - 5、注册监控线程优化,降低死锁几率; - 6、调度组件优化:针对永远不会触发的Cron禁止配置和启动;任务Cron最后一次触发后再也不会触发时,比如一次性任务,主动停止相关任务; - 7、任务列表交互优化,支持查看任务所属执行器的注册节点; -- 8、[ING]调度日志优化:支持设置日志保留天数,过期日志天维度记录报表,并清理;调度报表汇总实时数据和报表; -- 9、[ING]父子任务参数传递; -- 10、[ING]执行器端口复用,复用容器端口提供通讯服务; -- 11、[ING]执行器服务端口与注册端口分离,支持docker动态随机端口; -- 12、[ING]Cron在线生成工具; +- 8、DB重连优化,修复DB宕机重连后任务调度停止的问题,重连后自动加入调度集群触发任务调度; +- 9、[ING]调度日志优化:支持设置日志保留天数,过期日志天维度记录报表,并清理;调度报表汇总实时数据和报表; +- 10、[ING]父子任务参数传递; +- 11、[ING]执行器端口复用,复用容器端口提供通讯服务; +- 12、[ING]执行器服务端口与注册端口分离,支持docker动态随机端口; +- 13、[ING]Cron在线生成工具; ### TODO LIST diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobScheduleHelper.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobScheduleHelper.java index cb4433c7..01713766 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobScheduleHelper.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobScheduleHelper.java @@ -49,17 +49,20 @@ public class JobScheduleHelper { } logger.info(">>>>>>>>> init xxl-job admin scheduler success."); - Connection conn = null; while (!scheduleThreadToStop) { // Scan Job long start = System.currentTimeMillis(); + + Connection conn = null; + Boolean connAutoCommit = null; PreparedStatement preparedStatement = null; + boolean preReadSuc = true; try { - if (conn==null || conn.isClosed()) { - conn = XxlJobAdminConfig.getAdminConfig().getDataSource().getConnection(); - } + + conn = XxlJobAdminConfig.getAdminConfig().getDataSource().getConnection(); + connAutoCommit = conn.getAutoCommit(); conn.setAutoCommit(false); preparedStatement = conn.prepareStatement( "select * from xxl_job_lock where lock_name = 'schedule_lock' for update" ); @@ -169,11 +172,27 @@ public class JobScheduleHelper { } finally { // commit - try { - conn.commit(); - } catch (SQLException e) { - if (!scheduleThreadToStop) { - logger.error(e.getMessage(), e); + if (conn != null) { + try { + conn.commit(); + } catch (SQLException e) { + if (!scheduleThreadToStop) { + logger.error(e.getMessage(), e); + } + } + try { + conn.setAutoCommit(connAutoCommit); + } catch (SQLException e) { + if (!scheduleThreadToStop) { + logger.error(e.getMessage(), e); + } + } + try { + conn.close(); + } catch (SQLException e) { + if (!scheduleThreadToStop) { + logger.error(e.getMessage(), e); + } } } @@ -204,12 +223,7 @@ public class JobScheduleHelper { } } - if (conn != null) { - try { - conn.close(); - } catch (SQLException e) { - } - } + logger.info(">>>>>>>>>>> xxl-job, JobScheduleHelper#scheduleThread stop"); } }); diff --git a/xxl-job-admin/src/main/resources/static/js/jobinfo.index.1.js b/xxl-job-admin/src/main/resources/static/js/jobinfo.index.1.js index 415a9399..0d1408ac 100644 --- a/xxl-job-admin/src/main/resources/static/js/jobinfo.index.1.js +++ b/xxl-job-admin/src/main/resources/static/js/jobinfo.index.1.js @@ -90,9 +90,9 @@ $(function() { "render": function ( data, type, row ) { // status if (1 == data) { - return 'RUNNING'; + return 'RUNNING'; } else { - return 'STOP'; + return 'STOP'; } return data; }