jlinn / quartz-redis-jobstore

A Quartz Scheduler JobStore using Redis.
Apache License 2.0
136 stars 67 forks source link

Task will never fire again if I reboot my program. #63

Open IndustriousSnail opened 3 years ago

IndustriousSnail commented 3 years ago

Task will never fire again if I reboot my program. I follow the code of RedisJobStore and find that the trigger has 2 states, which are waiting and acquired(the redis key is prefix_acquired_triggers and prefix_waiting_triggers). If the task state was acquired when I shutdown my program, then QuartzSchedulerThread couldn't get the waiting triggers and couldn't fire the task.

The code of QuartzSchedulerThread is the following:

image

  1. The QuartzSchedulerThread will get triggers with waiting state and convert its waiting state to acquired state.(delete it and then add it)

image

  1. And in the below, the QuartzSchedulerThread fires the task and then converts its acquired state to a waiting state.

    QuartzSchedulerThread will repeat the action over and over again.

However: When I reboot my program and the state of task is acquired, and then the first step can't get the task so that the task will never be fired again.


PS: I found the task will be fired again after my program starts 5-10 minutes(The cron of my task is 0/5 * * * * ?).

Why can't the task recover right away when my program starts? And what should I do?