Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-11632

QuartzScheduledPollConsumerScheduler causes trigger misfires on each application start

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.19.0
    • 2.18.5, 2.19.4, 2.20.0
    • camel-quartz2
    • None
    • Unknown

    Description

      Recently I noticed that on application start Quartz founds and triggers misfired triggers:

      INFO o.s.s.q.LocalDataSourceJobStore - Handling 1 trigger(s) that missed their scheduled fire-time.
      

      That wasn't not the realistic case in my scenario - since I could see in a database that NEXT_FIRE_TIME is much ahead of the current time.

      After digging a little I found the issue in the QuartzScheduledPollConsumerScheduler:

       // Ensure the cron schedule is updated
      CronTrigger newTrigger = existingTrigger.getTriggerBuilder().withSchedule(CronScheduleBuilder.cronSchedule(getCron()).inTimeZone(getTimeZone())).build();
      
      quartzScheduler.rescheduleJob(triggerKey, newTrigger);
      

      There 2 issues here:
      1. Job is rescheduled even if nothing has been changed (i.e. cron expression, cron timezone)
      2. existingTrigger.getTriggerBuilder() returns trigger builder with START_TIME of existing trigger which, surely, is the past. This is causing the described bug - NEXT_FIRE_TIME is calculated based on the old START_TIME and is in the past also. So rescheduled trigger becomes misfired trigger immediately.

      Proposal:
      1. Do not reschedule job if nothing has been changed.
      2. If job needs to be rescheduled - make sure to set START_TIME to a current date.

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            oceansize Viktor Khoroshko
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: