石英作业找不到用于选择触发器的记录

发布于 2025-02-11 11:54:23 字数 4833 浏览 2 评论 0原文

石英问题

启动春季启动应用程序时,错误处理失火问题将出现很高的可能性。 以下是log以下

[2022-06-28 17:17:59.538] [ERROR] [QuartzScheduler_ProtectionQuartzScheduler-tw-node12191656407859503_MisfireHandler] [o.s.scheduling.quartz.LocalDataSourceJobStore] >>> [protection-web] msg=MisfireHandler: Error handling misfires: Couldn't retrieve trigger: No record found for selection of Trigger with key: 'com.test.protection.web.rest.service.quartz.job.LoadMetaQuartzJob.a002cf4a8a3a418fa62b8c1d6d071992[once]' and statement: SELECT * FROM QRTZ_SIMPLE_TRIGGERS WHERE SCHED_NAME = 'ProtectionQuartzScheduler' AND TRIGGER_NAME = ? AND TRIGGER_GROUP = ?
org.quartz.JobPersistenceException: Couldn't retrieve trigger: No record found for selection of Trigger with key: 'com.test.protection.web.rest.service.quartz.job.LoadMetaQuartzJob.a002cf4a8a3a418fa62b8c1d6d071992[once]' and statement: SELECT * FROM QRTZ_SIMPLE_TRIGGERS WHERE SCHED_NAME = 'ProtectionQuartzScheduler' AND TRIGGER_NAME = ? AND TRIGGER_GROUP = ?
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveTrigger(JobStoreSupport.java:1538)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.recoverMisfiredJobs(JobStoreSupport.java:984)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.doRecoverMisfires(JobStoreSupport.java:3264)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.manage(JobStoreSupport.java:4012)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.run(JobStoreSupport.java:4033)
Caused by: java.lang.IllegalStateException: No record found for selection of Trigger with key: 'com.test.protection.web.rest.service.quartz.job.LoadMetaQuartzJob.a002cf4a8a3a418fa62b8c1d6d071992[once]' and statement: SELECT * FROM QRTZ_SIMPLE_TRIGGERS WHERE SCHED_NAME = 'ProtectionQuartzScheduler' AND TRIGGER_NAME = ? AND TRIGGER_GROUP = ?
    at org.quartz.impl.jdbcjobstore.SimpleTriggerPersistenceDelegate.loadExtendedTriggerProperties(SimpleTriggerPersistenceDelegate.java:110)
    at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.selectTrigger(StdJDBCDelegate.java:1819)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveTrigger(JobStoreSupport.java:1536)
    ... 4 common frames omitted

是我的简单Java代码和Quartz的配置:

// DLockAcquired is my distributed lock
  @Async
  @EventListener(ApplicationReadyEvent.class)
  @DLockAcquired(keyName = "datasource-init")
  public void init() {
    logger.info("Initialize Synchronize datasource on startup ...");
        try {
      this.doSyncDatasource();
    } catch (Exception e) {
      logger.error("Initialize datasource failed, error: ", e);
    }

    aferInitialize.set(true);
  }

如果其他语句进行了一些语句,它将创建一个作业,如以下代码:

  public void scheduleJobOnce(JobDetail jobDetail, TriggerKey triggerKey)
      throws SchedulerException {
    Scheduler scheduler = schedulerFactoryBean.getScheduler();
    Trigger simpleTrigger = TriggerBuilder.newTrigger().startAt(new Date()).withIdentity(triggerKey)
        .withSchedule(SimpleScheduleBuilder.simpleSchedule().withRepeatCount(0)).build();
    try {
      scheduler.scheduleJob(jobDetail, simpleTrigger);
    } catch (SchedulerException e) {
      logger.error("Quartz schedule job failed, {}.",
          JsonUtil.parseObjectToString(jobDetail.getJobDataMap()), e);
      throw e;
    }

  }

我的Quartz config

org.quartz.scheduler.instanceName = ProtectionQuartzScheduler

org.quartz.scheduler.instanceId = AUTO
org.quartz.scheduler.rmi.export = false
org.quartz.scheduler.rmi.proxy = false
org.quartz.scheduler.wrapJobExecutionInUserTransaction = false


org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 10
org.quartz.threadPool.threadPriority = 5

org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true
org.quartz.jobStore.misfireThreshold = 60000


org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.acquireTriggersWithinLock = true
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.useProperties = true
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.jobStore.isClustered = true


org.quartz.jobStore.dataSource = qzDS
org.quartz.dataSource.qzDS.driver = com.mysql.cj.jdbc.Driver
org.quartz.dataSource.qzDS.provider = hikaricp
org.quartz.dataSource.qzDS.URL = jdbc:mysql://localhost:15307/quartz_db?useUnicode=true&characterEncoding=UTF8&useSSL=false&allowMultiQueries=true&failOverReadOnly=false&connectTimeout=10000&retriesAllDown=3&secondsBeforeRetryMaster=0&queriesBeforeRetryMaster=0
org.quartz.dataSource.qzDS.user = root
org.quartz.dataSource.qzDS.password = 123456
org.quartz.dataSource.qzDS.maxConnections = 10

如何解决此问题?

Quartz problem

When I start my spring boot application, Error handling misfires problem will occurre with high probability.
The following is the log

[2022-06-28 17:17:59.538] [ERROR] [QuartzScheduler_ProtectionQuartzScheduler-tw-node12191656407859503_MisfireHandler] [o.s.scheduling.quartz.LocalDataSourceJobStore] >>> [protection-web] msg=MisfireHandler: Error handling misfires: Couldn't retrieve trigger: No record found for selection of Trigger with key: 'com.test.protection.web.rest.service.quartz.job.LoadMetaQuartzJob.a002cf4a8a3a418fa62b8c1d6d071992[once]' and statement: SELECT * FROM QRTZ_SIMPLE_TRIGGERS WHERE SCHED_NAME = 'ProtectionQuartzScheduler' AND TRIGGER_NAME = ? AND TRIGGER_GROUP = ?
org.quartz.JobPersistenceException: Couldn't retrieve trigger: No record found for selection of Trigger with key: 'com.test.protection.web.rest.service.quartz.job.LoadMetaQuartzJob.a002cf4a8a3a418fa62b8c1d6d071992[once]' and statement: SELECT * FROM QRTZ_SIMPLE_TRIGGERS WHERE SCHED_NAME = 'ProtectionQuartzScheduler' AND TRIGGER_NAME = ? AND TRIGGER_GROUP = ?
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveTrigger(JobStoreSupport.java:1538)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.recoverMisfiredJobs(JobStoreSupport.java:984)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.doRecoverMisfires(JobStoreSupport.java:3264)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.manage(JobStoreSupport.java:4012)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.run(JobStoreSupport.java:4033)
Caused by: java.lang.IllegalStateException: No record found for selection of Trigger with key: 'com.test.protection.web.rest.service.quartz.job.LoadMetaQuartzJob.a002cf4a8a3a418fa62b8c1d6d071992[once]' and statement: SELECT * FROM QRTZ_SIMPLE_TRIGGERS WHERE SCHED_NAME = 'ProtectionQuartzScheduler' AND TRIGGER_NAME = ? AND TRIGGER_GROUP = ?
    at org.quartz.impl.jdbcjobstore.SimpleTriggerPersistenceDelegate.loadExtendedTriggerProperties(SimpleTriggerPersistenceDelegate.java:110)
    at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.selectTrigger(StdJDBCDelegate.java:1819)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveTrigger(JobStoreSupport.java:1536)
    ... 4 common frames omitted

The following is my simple java code and config of quartz:

// DLockAcquired is my distributed lock
  @Async
  @EventListener(ApplicationReadyEvent.class)
  @DLockAcquired(keyName = "datasource-init")
  public void init() {
    logger.info("Initialize Synchronize datasource on startup ...");
        try {
      this.doSyncDatasource();
    } catch (Exception e) {
      logger.error("Initialize datasource failed, error: ", e);
    }

    aferInitialize.set(true);
  }

After some if else statement, it will create a job as following code:

  public void scheduleJobOnce(JobDetail jobDetail, TriggerKey triggerKey)
      throws SchedulerException {
    Scheduler scheduler = schedulerFactoryBean.getScheduler();
    Trigger simpleTrigger = TriggerBuilder.newTrigger().startAt(new Date()).withIdentity(triggerKey)
        .withSchedule(SimpleScheduleBuilder.simpleSchedule().withRepeatCount(0)).build();
    try {
      scheduler.scheduleJob(jobDetail, simpleTrigger);
    } catch (SchedulerException e) {
      logger.error("Quartz schedule job failed, {}.",
          JsonUtil.parseObjectToString(jobDetail.getJobDataMap()), e);
      throw e;
    }

  }

My quartz config

org.quartz.scheduler.instanceName = ProtectionQuartzScheduler

org.quartz.scheduler.instanceId = AUTO
org.quartz.scheduler.rmi.export = false
org.quartz.scheduler.rmi.proxy = false
org.quartz.scheduler.wrapJobExecutionInUserTransaction = false


org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 10
org.quartz.threadPool.threadPriority = 5

org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true
org.quartz.jobStore.misfireThreshold = 60000


org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.acquireTriggersWithinLock = true
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.useProperties = true
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.jobStore.isClustered = true


org.quartz.jobStore.dataSource = qzDS
org.quartz.dataSource.qzDS.driver = com.mysql.cj.jdbc.Driver
org.quartz.dataSource.qzDS.provider = hikaricp
org.quartz.dataSource.qzDS.URL = jdbc:mysql://localhost:15307/quartz_db?useUnicode=true&characterEncoding=UTF8&useSSL=false&allowMultiQueries=true&failOverReadOnly=false&connectTimeout=10000&retriesAllDown=3&secondsBeforeRetryMaster=0&queriesBeforeRetryMaster=0
org.quartz.dataSource.qzDS.user = root
org.quartz.dataSource.qzDS.password = 123456
org.quartz.dataSource.qzDS.maxConnections = 10

How can I solve this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文