Quartz Scheduler突然停止运行并且没有异常错误

发布于 2024-07-14 05:20:56 字数 100 浏览 3 评论 0原文

我有一些石英工作,每天晚上 7 点运行。 突然就跑不了了。 我检查了我的 server.log,没有抛出任何异常。 任何人都知道可能是什么问题?

提前致谢

I have some quartz job which was running everyday at 7pm. Suddenly it failed to run. I check my server.log and there are no exception thrown. Anyone have any idea what could be the issue?

Thanks in advance

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

独自←快乐 2024-07-21 05:20:56

我遇到了类似的问题,但问题是,我在quartz属性中有10个线程quartz默认线程数,当我进行线程转储*时,我发现我在blocked stat中有10个作业,这意味着我无法运行更多线程。

快速修复此问题的方法是增加quartz 属性中线程池中的线程数。

实际的修复方法是检查我的代码以了解为什么有 10 个线程被阻塞。

*要进行线程转储,您可以使用 kill -3 java 进程号 > 将线程转储打印到应用程序标准输出,即如果您运行 tomcat,您会在 catalina.out 日志文件中找到它

I had a similar problem but the problem was, I had 10 threads quartz default number of threads in quartz properties and when I made thread dump* I found that I have 10 jobs in blocked stat, which means that I can't run any more threads.

A quick fix to this problem to increase the number of threads in the thread pool in the quartz properties.

The actual fix was reviewing my code to know why I had a 10 blocked threads.

*to do thread dump you can use kill -3 < java process number > which print the thread dump to your application standard output i.e if you running tomcat you find it in catalina.out log file

你对谁都笑 2024-07-21 05:20:56

就我而言,我有一个与数据库的开放连接。 当我没有更多可用连接时,我的线程将永远等待。 由于我无法开始任何其他工作,所以什么也没发生,一切都停滞不前。
我的建议是检查是否有任何可能需要释放的阻塞资源。

In my case I had an open connection to the database. When the I had no more connections available, my threads remained waiting forever. As I could not start any other jobs, nothing happened and everything stayed blocked.
My advice is for you to check if you have any blocking resource that you might need to release.

提赋 2024-07-21 05:20:56

如果您使用数据库来存储作业,请检查触发器的trigger_state。 现在我遇到了类似的问题(或者至少有类似的症状)。

每分钟运行一次的作业将使触发器处于“已获取”状态,并且永远不会再次运行。 和你一样,我在日志中什么也没看到。

我还看到同一问题的不同原因。 同样,作业只是停止运行,但触发器不处于“ACQUIRED”状态。 至今我还不知道原因。

到目前为止我所知道的是调度程序线程正在等待空闲的工作线程。 看起来所有工作线程都在等待信号量以更新其调度。 我还无法获得线程转储来验证工作线程正在等待什么。

我正在运行 Quartz 1.6.1 RC1。 请参阅此错误报告:http://jira.opensymphony.com/browse/QUARTZ-668

我想这就是我所看到的。

If you are using a database to store jobs, check the trigger_state of your trigger. Right now I'm seeing a similar problem (or at least it has similar symptoms).

A job that runs once a minute is leaving the trigger in "ACQUIRED" state and will never run again. Like you I'm seeing nothing the the log.

I'm also seeing a different cause of the same problem. Again, the job just stops running, but the trigger is not in the "ACQUIRED" state. So far I don't know the cause.

What I know so far is that the scheduler thread is waiting for a free worker thread. It looks like all of the worker threads are waiting for a semaphore in order to update their schedule. I haven't been able to get a thread dump yet to verify what the worker threads are waiting on.

I'm running Quartz 1.6.1 RC1. See this bug report: http://jira.opensymphony.com/browse/QUARTZ-668

I think that's what I'm seeing.

复古式 2024-07-21 05:20:56

检查是否有任何作业抛出异常。 将您的 Job exe 代码放入 try catch 块中,跟踪任何异常以解决问题。

Check if any Job is throwing an Exception. Put your Job exe code in a try catch block an trace any exception to troubleshoot the problem.

情深缘浅 2024-07-21 05:20:56

我遇到了类似的问题,不幸的是,上述答案都没有帮助我解决我的问题。 我使用的是quartz-2.3.2版本。 首先,我同意其他一些人的观点,其中大多数情况下调度程序未启动,是由于线程竞争条件引起的,该条件阻塞并尝试从进入临界区的线程获取标志,但不会释放它。 这只是一种糟糕的代码,但无论如何,我不想像其他人那样再说一遍同样的事情。我想提出我的解决方案,为您提供解决问题的方法。

假设您使用像下面这样的 Cron 调度程序,我将提供一个详细的示例,

这是 SimpleJob 类

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.JobKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

public class SimpleJob implements Job {

    private static Logger _log = LoggerFactory.getLogger(SimpleJob.class);

    public SimpleJob() {
    }

    public void execute(JobExecutionContext context)
            throws JobExecutionException {

        // This job simply prints out its job name and the
        // date and time that it is running
        JobKey jobKey = context.getJobDetail().getKey();
        _log.info("SimpleJob says: " + jobKey + " executing at " + new Date());
    }

}

这是您的主类

import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.impl.StdSchedulerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.quartz.CronScheduleBuilder.cronSchedule;
import static org.quartz.JobBuilder.newJob;
import static org.quartz.TriggerBuilder.newTrigger;

public class CronTriggerExample {

    public void run() throws Exception {
        Logger log = LoggerFactory.getLogger(CronTriggerExample.class);

        log.info("------- Initializing -------------------");

        // First we must get a reference to a scheduler
        JobDetail job = newJob(SimpleJob.class)
                .withIdentity("job1", "group1").build();

        CronTrigger trigger = newTrigger()
            .withIdentity("trigger1", "group1")
            .withSchedule(cronSchedule("10 10/5 * ? * *").withMisfireHandlingInstructionFireAndProceed())
            .build();
        Scheduler scheduler = new StdSchedulerFactory().getScheduler();
        scheduler.start();
        scheduler.scheduleJob(job, trigger);
    }

    public static void main(String[] args) throws Exception {

        CronTriggerExample example = new CronTriggerExample();
        example.run();
    }
}

下面的 cron 表达式表示在秒 :10 处,从每小时 10 分开始,每 5 分钟一次。

cronSchedule("10 10/5 * ? * *")

如果您注意到这里最有趣的部分是

withMisfireHandlingInstructionFireAndProceed()

如果您的触发器在失火情况下感到这是解决问题的关键,它会指示您的调度程序立即被触发。 使用

withMisfireHandlingInstructionDoNothing()

另一种情况是在失火情况下 cronTrigger 将在调度程序设置的启动时间下一次触发。 例如,在我们的例子中,每小时 10 分 10 分开始,每 5 分钟一次。

I had a similar problem and unfortunately, none of the above answers helped me to figure out my problem. I am using quartz-2.3.2 version. First of all, i agree with some others, wherein most of the cases the scheduler not fired up, is caused due to threads race conditions which blocked and try to acquire the flag from the thread entered the critical zone and it does not release it. This simply smells a kind of bad code but anyway, i don't want to say again the same thing like the others did.I want to come up with my solution to give you the way on which i fixed the problem.

Assuming you use a Cron scheduler like the following way i will provide a detailed example

this is the SimpleJob class

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.JobKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

public class SimpleJob implements Job {

    private static Logger _log = LoggerFactory.getLogger(SimpleJob.class);

    public SimpleJob() {
    }

    public void execute(JobExecutionContext context)
            throws JobExecutionException {

        // This job simply prints out its job name and the
        // date and time that it is running
        JobKey jobKey = context.getJobDetail().getKey();
        _log.info("SimpleJob says: " + jobKey + " executing at " + new Date());
    }

}

This is your main class

import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.impl.StdSchedulerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.quartz.CronScheduleBuilder.cronSchedule;
import static org.quartz.JobBuilder.newJob;
import static org.quartz.TriggerBuilder.newTrigger;

public class CronTriggerExample {

    public void run() throws Exception {
        Logger log = LoggerFactory.getLogger(CronTriggerExample.class);

        log.info("------- Initializing -------------------");

        // First we must get a reference to a scheduler
        JobDetail job = newJob(SimpleJob.class)
                .withIdentity("job1", "group1").build();

        CronTrigger trigger = newTrigger()
            .withIdentity("trigger1", "group1")
            .withSchedule(cronSchedule("10 10/5 * ? * *").withMisfireHandlingInstructionFireAndProceed())
            .build();
        Scheduler scheduler = new StdSchedulerFactory().getScheduler();
        scheduler.start();
        scheduler.scheduleJob(job, trigger);
    }

    public static void main(String[] args) throws Exception {

        CronTriggerExample example = new CronTriggerExample();
        example.run();
    }
}

The below cron expression means At second :10, every 5 minutes starting at minute :10, of every hour.

cronSchedule("10 10/5 * ? * *")

If you notice the most interesting part here is the

withMisfireHandlingInstructionFireAndProceed()

This is the key to solve your problem if your trigger is felt in a misfire situation, it instructs your scheduler to be fired immediately. An alternative occasion is to use

withMisfireHandlingInstructionDoNothing()

where upon a mis-fire situation the cronTrigger will be next fired at the started time which the scheduler is set on. For example in our case in At second :10, every 5 minutes starting at minute :10, of every hour.

山有枢 2024-07-21 05:20:56

我有类似但有些不同的问题。 我的调度程序在开发环境中运行良好。 在这个调度程序中,我正在执行更新事务等工作。

当我们将构建转移到生产环境时,调度程序运行良好,直到周六一切都很好。 星期六我的日程安排突然停止了。 我在我的应用程序服务器(OC4J)中没有发现与调度程序相关的任何异常。

我使用的是quartz-1.5.2版本。 我无法追踪问题的实际根本原因。

我在应用程序服务器启动时启动调度程序。 如果出现问题,它就会停止工作。 那么我就没有机会启动它们。

我认为如果我再次使用一些 jsp 请求调用 init servlet 来启动调度程序会产生不同。 这就像查看个人资料(我们的调度程序的运行状况并重新启动它们)。 如果您有更好的方法来启动调度程序,请建议我。

I had similar but somewhat different problem. My scheduler is running fine in the development environment. In this scheduler I am doing the jobs like updating the transactions, etc.

When we move the build to production, the schedulers ran well and everything was fine until Saturday. On Saturday my scheduler was suddenly stopped. I didn't find any exception related to the scheduler in my app server (OC4J).

I am using quartz-1.5.2 version. I am unable to trace the actual root cause of the problem.

I am starting the scheduler on startup of the application server. If something goes wrong then it stops working. Then I am not having any chance to start them.

I think if I start the schedulers by calling the init servlet using some jsp request again makes the difference. It will be like seeing the profile (health of our schedulers and starting them again). If you have any better approach to start the scheduler then please suggest me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文