From e73be8175ccfa3bc9575e503d778ed143c297ef4 Mon Sep 17 00:00:00 2001 From: xuxueli <931591021@qq.com> Date: Wed, 20 Nov 2019 18:22:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E5=BA=A6=E4=B8=AD=E5=BF=83=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E5=88=A0=E9=99=A4=E4=BC=98=E5=8C=96=EF=BC=8C=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E5=88=86=E9=A1=B5=E8=8E=B7=E5=8F=96ID=E5=B9=B6?= =?UTF-8?q?=E6=A0=B9=E6=8D=AEID=E5=88=A0=E9=99=A4=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=EF=BC=8C=E9=81=BF=E5=85=8D=E6=89=B9=E9=87=8F=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=B5=B7=E9=87=8F=E6=97=A5=E5=BF=97=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=AD=BB=E9=94=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/XXL-JOB官方文档.md | 5 ++- .../admin/controller/JobLogController.java | 9 ++++- .../com/xxl/job/admin/dao/XxlJobLogDao.java | 10 +++-- .../mybatis-mapper/XxlJobLogMapper.xml | 40 ++++++++++++------- 4 files changed, 42 insertions(+), 22 deletions(-) diff --git a/doc/XXL-JOB官方文档.md b/doc/XXL-JOB官方文档.md index 8c99c712..b6e90ba8 100644 --- a/doc/XXL-JOB官方文档.md +++ b/doc/XXL-JOB官方文档.md @@ -1590,8 +1590,8 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段 - 19、调度中心移除SQL中的 "now()" 函数;集群部署时不再依赖DB时钟,仅需要保证调度中心应用节点时钟一致即可; - 20、xxl-rpc服务端线程优化,降低线程内存开销; - 21、调度中心回调API服务改为restful方式; -- 22、[ING]调度日志优化:支持设置日志保留天数,过期日志天维度记录报表,并清理;调度报表汇总实时数据和报表; -- 23、[ING]调度中心日志删除,改为分页获取ID,根据ID删除的方式; +- 22、调度中心日志删除优化,改为分页获取ID并根据ID删除的方式,避免批量删除海量日志导致死锁问题; +- 23、[ING]调度日志优化:支持设置日志保留天数,过期日志天维度记录报表,并清理;调度报表汇总实时数据和报表; @@ -1632,6 +1632,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段 - 34、通讯调整;双向HTTP,回调和其他API自定义AccessToken,Restful,执行器复用容器端口; - 35、父子任务参数传递;流程任务等,透传动态参数; - 36、任务操作API服务调整为和回调服务一致,降低接入成本; +- 37、新增执行器描述、任务描述属性; ## 七、其他 diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java index 016b0169..d378aac7 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java @@ -216,7 +216,14 @@ public class JobLogController { return new ReturnT(ReturnT.FAIL_CODE, I18nUtil.getString("joblog_clean_type_unvalid")); } - xxlJobLogDao.clearLog(jobGroup, jobId, clearBeforeTime, clearBeforeNum); + List logIds = null; + do { + logIds = xxlJobLogDao.findClearLogIds(jobGroup, jobId, clearBeforeTime, clearBeforeNum, 1000); + if (logIds!=null && logIds.size()>0) { + xxlJobLogDao.clearLog(logIds); + } + } while (logIds!=null && logIds.size()>0); + return ReturnT.SUCCESS; } diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java index b4d93ed7..0bd3dbdf 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java @@ -46,10 +46,12 @@ public interface XxlJobLogDao { public List> triggerCountByDay(@Param("from") Date from, @Param("to") Date to); - public int clearLog(@Param("jobGroup") int jobGroup, - @Param("jobId") int jobId, - @Param("clearBeforeTime") Date clearBeforeTime, - @Param("clearBeforeNum") int clearBeforeNum); + public List findClearLogIds(@Param("jobGroup") int jobGroup, + @Param("jobId") int jobId, + @Param("clearBeforeTime") Date clearBeforeTime, + @Param("clearBeforeNum") int clearBeforeNum, + @Param("pagesize") int pagesize); + public int clearLog(@Param("logIds") List logIds); public List findFailJobLogIds(@Param("pagesize") int pagesize); diff --git a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml index 2c209cbe..70f706e2 100644 --- a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml +++ b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml @@ -186,8 +186,8 @@ ORDER BY triggerDay - - delete from xxl_job_log + + + + delete from xxl_job_log + WHERE id in + + #{item} +