Skip to content

[JobRunner] Uncaught exceptions leave jobs in "running" state #385

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? No Sign in to your account

Closed
msheakoski opened this issue Feb 28, 2018 · 1 comment
Closed

[JobRunner] Uncaught exceptions leave jobs in "running" state #385

msheakoski opened this issue Feb 28, 2018 · 1 comment

Comments

@msheakoski
Copy link
Contributor

msheakoski commented Feb 28, 2018

The docs say to not catch exceptions and fail fast when processing messages, however, if an exception occurs within a running job, things do not properly clean up and jobs are left in a "enqueue.job_queue.status.running" state. You are also no longer able to execute a job with the same name again because it is stuck in the "enqueue_job_unique" table (DBAL transport).

I think in

$result = call_user_func($runCallback, $jobRunner, $childJob);
this line should be wrapped in a try/catch block, failed, and then re-throw the exception so it bubbles up to the message processor. Something similar to:

try {
    $result = call_user_func($runCallback, $jobRunner, $childJob);
} catch (Exception $e) { // for PHP 5
    $this->jobProcessor->failChildJob($childJob);
    throw $e;
} catch (Throwable $e) { // for PHP 7+
    $this->jobProcessor->failChildJob($childJob);
    throw $e;
}

I am not entirely familiar with the codebase so I may be missing something, but hopefully you get the right idea from my example.

@makasim
Copy link
Member

makasim commented Mar 1, 2018

It makes sense to me. @ASKozienko what do you think about this?

No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants