mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
fix: use fixedDelay instead of fixedRate to fix the problem of scheduling of multiple threads causing system crashes #213
This commit is contained in:
parent
a1a5ade215
commit
b4288225a0
@ -70,9 +70,10 @@ public class OmsScheduleService {
|
|||||||
private static final long SCHEDULE_RATE = 15000;
|
private static final long SCHEDULE_RATE = 15000;
|
||||||
|
|
||||||
@Async("omsTimingPool")
|
@Async("omsTimingPool")
|
||||||
@Scheduled(fixedRate = SCHEDULE_RATE)
|
@Scheduled(fixedDelay = SCHEDULE_RATE)
|
||||||
public void timingSchedule() {
|
public void timingSchedule() {
|
||||||
|
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||||
|
|
||||||
// 先查询DB,查看本机需要负责的任务
|
// 先查询DB,查看本机需要负责的任务
|
||||||
@ -111,6 +112,11 @@ public class OmsScheduleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.info("[JobScheduleService] cron schedule: {}, workflow schedule: {}, frequent schedule: {}.", cronTime, wfTime, stopwatch.stop());
|
log.info("[JobScheduleService] cron schedule: {}, workflow schedule: {}, frequent schedule: {}.", cronTime, wfTime, stopwatch.stop());
|
||||||
|
|
||||||
|
long cost = System.currentTimeMillis() - start;
|
||||||
|
if (cost > SCHEDULE_RATE) {
|
||||||
|
log.warn("[JobScheduleService] The database query is using too much time({}ms), please check if the database load is too high!", cost);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user