⚡ Sangsakala Proxy 🏠 Home
Skip to content

NPE thrown when acquiring next trigger due to null next fire time value #189

Closed

Description

@Dwisf

During a soak testing of our application using Quartz (version 2.2.3), we notice the following exceptions being thrown from time to time:

org.quartz.core.ErrorLogger ERROR --- An error occurred while scanning for the next triggers to fire. 
java.lang.NullPointerException: null
	at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:2837)
	... 5 common frames omitted
Wrapped by: org.quartz.JobPersistenceException: Couldn't acquire next trigger: null
	at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:2864)
	at org.quartz.impl.jdbcjobstore.JobStoreSupport$40.execute(JobStoreSupport.java:2759)
	at org.quartz.impl.jdbcjobstore.JobStoreSupport$40.execute(JobStoreSupport.java:2757)
	at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3803)
	at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTriggers(JobStoreSupport.java:2756)
	at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:272)

Line 2837 of JobStoreSupport.java corresponds to the following code:

...
if (nextTrigger.getNextFireTime().getTime() > batchEnd) {
...

That is getNextFireTime() is null. The API for this method states ...If the trigger will not fire again, null will be returned. It looks like this code needs to check if getNextFireTime() is null before doing a getTime().

Is this a correct assessment?

Activity

  1. bsiamionau commented on Dec 26, 2017

    @bsiamionau

    Any progress on this?

  2. sudhanmoghe commented on Jan 8, 2018

    @sudhanmoghe

    We are also getting this error.
    We started getting this error after adding 2nd node to cluster. We never got this error with single node.
    We see the exception stack trace in logs. 285 in last one month. But, no issue in actual job execution. No failed or pending job.
    We only have CRON jobs or Simple JOBS. I don't see any NEXT_FIRE_TIME < 0 in TRIGGERS table. Not sure what is causing the NPE and how to fix that.
    We are running cluster with this config.
    org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
    org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
    org.quartz.jobStore.isClustered=true

    Hope these details help in fixing the issue. Let me know if you need more details or want me to try out some thing.

  3. sudhanmoghe commented on Jan 8, 2018

    @sudhanmoghe

    Found one more bug report with possible solution. #174
    I have updated my config with
    org.quartz.jobStore.acquireTriggersWithinLock=true.
    Will update in weeks time to confirm whether that solved the problem.

  4. added a commit that references this issue on Feb 15, 2019
  5. zemian commented on Feb 15, 2019

    @zemian
    Contributor

    I have put in a PR for this #361

    However I should point out that this is not so much as bug than improvement to the code. Per design, there should not be any trigger store in DB with nextFireTime that will return null. If it does, it should already been remove from DB. If we do see this case, there is something wrong with the Trigger implementation of some kind of bad data with this trigger. There is no way to recover from this since it's unexpected. So as code improvement, we log a WARNING. Users should investigate why their trigger is in this state, and manually clean up the data in DB. Please do report new issue if you continue to see this.

  6. added 2 commits that reference this issue on Feb 15, 2019
  7. added 4 commits that reference this issue on Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions