diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobFailMonitorHelper.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobFailMonitorHelper.java index 8409d7b3dd..a9fc5ec482 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobFailMonitorHelper.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobFailMonitorHelper.java @@ -18,7 +18,7 @@ */ public class JobFailMonitorHelper { private static Logger logger = LoggerFactory.getLogger(JobFailMonitorHelper.class); - + private static JobFailMonitorHelper instance = new JobFailMonitorHelper(); public static JobFailMonitorHelper getInstance(){ return instance; @@ -33,12 +33,12 @@ public void start(){ @Override public void run() { - + Long lastFailLogId = null; // monitor while (!toStop) { try { - List failLogIds = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().findFailJobLogIds(1000); + List failLogIds = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().findFailJobLogIds(lastFailLogId,1000); if (failLogIds!=null && !failLogIds.isEmpty()) { for (long failLogId: failLogIds) { @@ -68,6 +68,7 @@ public void run() { } XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().updateAlarmStatus(failLogId, -1, newAlarmStatus); + lastFailLogId = failLogId; } } 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 62fa3b4f90..0694aef9dd 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 @@ -30,7 +30,7 @@ public int pageListCount(@Param("offset") int offset, @Param("triggerTimeStart") Date triggerTimeStart, @Param("triggerTimeEnd") Date triggerTimeEnd, @Param("logStatus") int logStatus); - + public XxlJobLog load(@Param("id") long id); public long save(XxlJobLog xxlJobLog); @@ -38,7 +38,7 @@ public int pageListCount(@Param("offset") int offset, public int updateTriggerInfo(XxlJobLog xxlJobLog); public int updateHandleInfo(XxlJobLog xxlJobLog); - + public int delete(@Param("jobId") int jobId); public Map findLogReport(@Param("from") Date from, @@ -51,7 +51,7 @@ public List findClearLogIds(@Param("jobGroup") int jobGroup, @Param("pagesize") int pagesize); public int clearLog(@Param("logIds") List logIds); - public List findFailJobLogIds(@Param("pagesize") int pagesize); + public List findFailJobLogIds(@Param("lastJobLogId") Long lastJobLogId, @Param("pagesize") int pagesize); public int updateAlarmStatus(@Param("logId") long logId, @Param("oldAlarmStatus") int oldAlarmStatus, 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 4155f17982..e8f969073a 100644 --- a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml +++ b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml @@ -1,8 +1,8 @@ - - + @@ -14,11 +14,11 @@ - + - + @@ -43,7 +43,7 @@ t.handle_msg, t.alarm_status - + - + - + - + INSERT INTO xxl_job_log ( `job_group`, @@ -132,7 +132,7 @@ #{handleCode} ); @@ -152,13 +152,13 @@ UPDATE xxl_job_log - SET - `handle_time`= #{handleTime}, + SET + `handle_time`= #{handleTime}, `handle_code`= #{handleCode}, `handle_msg`= #{handleMsg} WHERE `id`= #{id} - + delete from xxl_job_log WHERE job_id = #{jobId} @@ -235,6 +235,9 @@ (handle_code = 200) ) AND `alarm_status` = 0 + + AND id ]]> #{lastJobLogId} + ORDER BY id ASC LIMIT #{pagesize} @@ -270,4 +273,4 @@ ) --> - \ No newline at end of file +