1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 12:00:55 +01:00

Recover more cleanly from worker tasks with unconstructable classes

Summary:
This is unusual, but if `getWorkerInstance()` throws we end up with an undefined `$worker` when recovering from the exception.

Instead, handle this case slightly more gracefully.

The easiest way to hit this is to schedule a task for a worker that doesn't exist (or remove an existing worker, which is what I did to hit it).

Test Plan: Saw a more graceful error recovery; ran some normal successful tasks out of the queue.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D11413
This commit is contained in:
epriestley 2015-01-15 15:57:02 -08:00
parent 9f29af108b
commit b9788fed00

View file

@ -135,6 +135,7 @@ final class PhabricatorWorkerActiveTask extends PhabricatorWorkerTask {
$this->checkLease(); $this->checkLease();
$did_succeed = false; $did_succeed = false;
$worker = null;
try { try {
$worker = $this->getWorkerInstance(); $worker = $this->getWorkerInstance();
@ -182,7 +183,11 @@ final class PhabricatorWorkerActiveTask extends PhabricatorWorkerTask {
$this->setFailureCount($this->getFailureCount() + 1); $this->setFailureCount($this->getFailureCount() + 1);
$this->setFailureTime(time()); $this->setFailureTime(time());
$retry = null;
if ($worker) {
$retry = $worker->getWaitBeforeRetry($this); $retry = $worker->getWaitBeforeRetry($this);
}
$retry = coalesce( $retry = coalesce(
$retry, $retry,
PhabricatorWorkerLeaseQuery::getDefaultWaitBeforeRetry()); PhabricatorWorkerLeaseQuery::getDefaultWaitBeforeRetry());