From b9788fed0060000a193871fb9f6e43c22a137a54 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 15 Jan 2015 15:57:02 -0800 Subject: [PATCH] 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 --- .../daemon/workers/storage/PhabricatorWorkerActiveTask.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php b/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php index 6e3b6ad8fa..36ada93a13 100644 --- a/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php +++ b/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php @@ -135,6 +135,7 @@ final class PhabricatorWorkerActiveTask extends PhabricatorWorkerTask { $this->checkLease(); $did_succeed = false; + $worker = null; try { $worker = $this->getWorkerInstance(); @@ -182,7 +183,11 @@ final class PhabricatorWorkerActiveTask extends PhabricatorWorkerTask { $this->setFailureCount($this->getFailureCount() + 1); $this->setFailureTime(time()); - $retry = $worker->getWaitBeforeRetry($this); + $retry = null; + if ($worker) { + $retry = $worker->getWaitBeforeRetry($this); + } + $retry = coalesce( $retry, PhabricatorWorkerLeaseQuery::getDefaultWaitBeforeRetry());