We are trying to schedule a simple job trigger from our Springboot application in kubernetes but we are getting the following error,
org.quartz.JobPersistenceException: Couldn't acquire next trigger: Couldn't retrieve trigger: No record found for selection of Trigger with key: 'ERICSSON_POLLING_JOB.10.81.100.3' and statement: SELECT FROM QRTZ_SIMPLE_TRIGGERS WHERE SCHED_NAME = 'quartzScheduler' AND TRIGGER_NAME = ? AND TRIGGER_GROUP = ?
at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:2923) ~[quartz-2.3.2.jar:na]
at org.quartz.impl.jdbcjobstore.JobStoreSupport$41.execute(JobStoreSupport.java:2805) ~[quartz-2.3.2.jar:na]
at org.quartz.impl.jdbcjobstore.JobStoreSupport$41.execute(JobStoreSupport.java:2803) ~[quartz-2.3.2.jar:na]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3864) ~[quartz-2.3.2.jar:na]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTriggers(JobStoreSupport.java:2802) ~[quartz-2.3.2.jar:na]
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:287) ~[quartz-2.3.2.jar:na]
Caused by: org.quartz.JobPersistenceException: Couldn't retrieve trigger: No record found for selection of Trigger with key: 'ERICSSON_POLLING_JOB.10.81.100.3' and statement: SELECT FROM QRTZ_SIMPLE_TRIGGERS WHERE SCHED_NAME = 'quartzScheduler' AND TRIGGER_NAME = ? AND TRIGGER_GROUP = ?
at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveTrigger(JobStoreSupport.java:1538) ~[quartz-2.3.2.jar:na]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:2854) ~[quartz-2.3.2.jar:na]
... 5 common frames omitted
Caused by: java.lang.IllegalStateException: No record found for selection of Trigger with key: 'ERICSSON_POLLING_JOB.10.81.100.3' and statement: SELECT * FROM QRTZ_SIMPLE_TRIGGERS WHERE SCHED_NAME = 'quartzScheduler' AND TRIGGER_NAME = ? AND TRIGGER_GROUP = ?
at org.quartz.impl.jdbcjobstore.SimpleTriggerPersistenceDelegate.loadExtendedTriggerProperties(SimpleTriggerPersistenceDelegate.java:110) ~[quartz-2.3.2.jar:na]
at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.selectTrigger(StdJDBCDelegate.java:1819) ~[quartz-2.3.2.jar:na]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveTrigger(JobStoreSupport.java:1536) ~[quartz-2.3.2.jar:na]
... 6 common frames omitted
We are using a simple code only to schedule but encountering the above error
We don't have any stale data in our quartz tables. This error is not occurring always, but at times. Can you please give a solution? We are using quartz 2.3.2
In continuation to the issue mentioned above, I've extended the JobStore to Synchronize the threads
This class is responsible to maintain synchronization between Created and Fired Triggers
*/
@Component
@Log4j2
public class MyCustomJobStore extends LocalDataSourceJobStore {
/**
This method will lock the Jobstore till the job and trigger are created
*/
@Override
public void storeJobAndTrigger(JobDetail newJob, OperableTrigger newTrigger) throws JobPersistenceException {
// Logic to store job and trigger
synchronized (JobStore.class) {
super.storeJobAndTrigger(newJob, newTrigger);
log.info("stored job ....." + newJob.getKey().getName());
log.info("stored Trigger....." + newTrigger.getKey().getName());
}
}
/**
This method will lock the JobStore until it acquires next triggers
*/
@Override
public List acquireNextTriggers(long noLaterThan, int maxCount, long timeWindow)
throws JobPersistenceException {
// TODO Auto-generated method stub
List operTriggers = null;
synchronized (JobStore.class) {
operTriggers = super.acquireNextTriggers(noLaterThan, maxCount, timeWindow);
}
return operTriggers;
}
LocalDataSourceJobStore is part of the Spring project, not part of Quartz. Quartz' job stores use row locking in the database to avoid this concurrency.
We are trying to schedule a simple job trigger from our Springboot application in kubernetes but we are getting the following error,
org.quartz.JobPersistenceException: Couldn't acquire next trigger: Couldn't retrieve trigger: No record found for selection of Trigger with key: 'ERICSSON_POLLING_JOB.10.81.100.3' and statement: SELECT FROM QRTZ_SIMPLE_TRIGGERS WHERE SCHED_NAME = 'quartzScheduler' AND TRIGGER_NAME = ? AND TRIGGER_GROUP = ? at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:2923) ~[quartz-2.3.2.jar:na] at org.quartz.impl.jdbcjobstore.JobStoreSupport$41.execute(JobStoreSupport.java:2805) ~[quartz-2.3.2.jar:na] at org.quartz.impl.jdbcjobstore.JobStoreSupport$41.execute(JobStoreSupport.java:2803) ~[quartz-2.3.2.jar:na] at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3864) ~[quartz-2.3.2.jar:na] at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTriggers(JobStoreSupport.java:2802) ~[quartz-2.3.2.jar:na] at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:287) ~[quartz-2.3.2.jar:na] Caused by: org.quartz.JobPersistenceException: Couldn't retrieve trigger: No record found for selection of Trigger with key: 'ERICSSON_POLLING_JOB.10.81.100.3' and statement: SELECT FROM QRTZ_SIMPLE_TRIGGERS WHERE SCHED_NAME = 'quartzScheduler' AND TRIGGER_NAME = ? AND TRIGGER_GROUP = ? at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveTrigger(JobStoreSupport.java:1538) ~[quartz-2.3.2.jar:na] at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:2854) ~[quartz-2.3.2.jar:na] ... 5 common frames omitted Caused by: java.lang.IllegalStateException: No record found for selection of Trigger with key: 'ERICSSON_POLLING_JOB.10.81.100.3' and statement: SELECT * FROM QRTZ_SIMPLE_TRIGGERS WHERE SCHED_NAME = 'quartzScheduler' AND TRIGGER_NAME = ? AND TRIGGER_GROUP = ? at org.quartz.impl.jdbcjobstore.SimpleTriggerPersistenceDelegate.loadExtendedTriggerProperties(SimpleTriggerPersistenceDelegate.java:110) ~[quartz-2.3.2.jar:na] at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.selectTrigger(StdJDBCDelegate.java:1819) ~[quartz-2.3.2.jar:na] at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveTrigger(JobStoreSupport.java:1536) ~[quartz-2.3.2.jar:na] ... 6 common frames omitted
We are using a simple code only to schedule but encountering the above error
if (!scheduler.checkExists(JobKey.jobKey(host + COLON + filecollectorHost, ERICSSON_POLLING_JOB))) { JobDetail job = newJob(FtpsEricssonJobExecutor.class) .withIdentity(host + COLON + filecollectorHost, ERICSSON_POLLING_JOB).usingJobData("host", host) .requestRecovery().build(); Trigger trigger = newTrigger().withIdentity(host + COLON + filecollectorHost, ERICSSON_POLLING_JOB) .withSchedule(simpleSchedule()).build(); try { scheduler.scheduleJob(job, trigger); } catch (SchedulerException e) { log.error(e); } log.info("Scheduled job/trigger: " + job + "/" + trigger); }
We don't have any stale data in our quartz tables. This error is not occurring always, but at times. Can you please give a solution? We are using quartz 2.3.2
In continuation to the issue mentioned above, I've extended the JobStore to Synchronize the threads
import java.util.List;
import org.quartz.JobDetail; import org.quartz.JobPersistenceException; import org.quartz.spi.JobStore; import org.quartz.spi.OperableTrigger; import org.springframework.scheduling.quartz.LocalDataSourceJobStore; import org.springframework.stereotype.Component;
import lombok.extern.log4j.Log4j2;
/**
This class is responsible to maintain synchronization between Created and Fired Triggers */ @Component @Log4j2 public class MyCustomJobStore extends LocalDataSourceJobStore {
/**
}
/**
}
Is there any better approach to fix this issue?