diff --git a/src/applications/repository/worker/PhabricatorRepositoryCommitParserWorker.php b/src/applications/repository/worker/PhabricatorRepositoryCommitParserWorker.php index f6e2661b87..b565d30c55 100644 --- a/src/applications/repository/worker/PhabricatorRepositoryCommitParserWorker.php +++ b/src/applications/repository/worker/PhabricatorRepositoryCommitParserWorker.php @@ -1,124 +1,127 @@ commit) { return $this->commit; } $commit_id = idx($this->getTaskData(), 'commitID'); if (!$commit_id) { throw new PhabricatorWorkerPermanentFailureException( pht('No "%s" in task data.', 'commitID')); } $commit = id(new DiffusionCommitQuery()) ->setViewer(PhabricatorUser::getOmnipotentUser()) ->withIDs(array($commit_id)) ->executeOne(); if (!$commit) { throw new PhabricatorWorkerPermanentFailureException( pht('Commit "%s" does not exist.', $commit_id)); } if ($commit->isUnreachable()) { throw new PhabricatorWorkerPermanentFailureException( pht( - 'Commit "%s" has been deleted: it is no longer reachable from '. - 'any ref.', + 'Commit "%s" (with internal ID "%s") is no longer reachable from '. + 'any branch, tag, or ref in this repository, so it will not be '. + 'imported. This usually means that the branch the commit was on '. + 'was deleted or overwritten.', + $commit->getMonogram(), $commit_id)); } $this->commit = $commit; return $commit; } final protected function doWork() { $commit = $this->loadCommit(); $repository = $commit->getRepository(); $this->repository = $repository; $this->parseCommit($repository, $this->commit); } final protected function shouldQueueFollowupTasks() { return !idx($this->getTaskData(), 'only'); } protected function getImportStepFlag() { return null; } final protected function shouldSkipImportStep() { // If this step has already been performed and this is a "natural" task // which was queued by the normal daemons, decline to do the work again. // This mitigates races if commits are rapidly deleted and revived. $flag = $this->getImportStepFlag(); if (!$flag) { // This step doesn't have an associated flag. return false; } $commit = $this->commit; if (!$commit->isPartiallyImported($flag)) { // This commit doesn't have the flag set yet. return false; } if (!$this->shouldQueueFollowupTasks()) { // This task was queued by administrative tools, so do the work even // if it duplicates existing work. return false; } $this->log( "%s\n", pht( 'Skipping import step; this step was previously completed for '. 'this commit.')); return true; } abstract protected function parseCommit( PhabricatorRepository $repository, PhabricatorRepositoryCommit $commit); protected function isBadCommit(PhabricatorRepositoryCommit $commit) { $repository = new PhabricatorRepository(); $bad_commit = queryfx_one( $repository->establishConnection('w'), 'SELECT * FROM %T WHERE fullCommitName = %s', PhabricatorRepository::TABLE_BADCOMMIT, $commit->getMonogram()); return (bool)$bad_commit; } public function renderForDisplay(PhabricatorUser $viewer) { $suffix = parent::renderForDisplay($viewer); $commit = id(new DiffusionCommitQuery()) ->setViewer($viewer) ->withIDs(array(idx($this->getTaskData(), 'commitID'))) ->executeOne(); if (!$commit) { return $suffix; } $link = DiffusionView::linkCommit( $commit->getRepository(), $commit->getCommitIdentifier()); return array($link, $suffix); } } diff --git a/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php b/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php index 2b54b9ab51..49e283c946 100644 --- a/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php +++ b/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php @@ -1,55 +1,57 @@ setLimit(1) ->execute(); if ($tasks) { $this->willBeginWork(); foreach ($tasks as $task) { $id = $task->getID(); $class = $task->getTaskClass(); $this->log(pht('Working on task %d (%s)...', $id, $class)); $task = $task->executeTask(); $ex = $task->getExecutionException(); if ($ex) { if ($ex instanceof PhabricatorWorkerPermanentFailureException) { - throw new PhutilProxyException( - pht('Permanent failure while executing Task ID %d.', $id), - $ex); + $this->log( + pht( + 'Task %d was cancelled: %s', + $id, + $ex->getMessage())); } else if ($ex instanceof PhabricatorWorkerYieldException) { $this->log(pht('Task %s yielded.', $id)); } else { $this->log(pht('Task %d failed!', $id)); throw new PhutilProxyException( pht('Error while executing Task ID %d.', $id), $ex); } } else { $this->log(pht('Task %s complete! Moved to archive.', $id)); } } $sleep = 0; } else { // When there's no work, sleep for one second. The pool will // autoscale down if we're continuously idle for an extended period // of time. $this->willBeginIdle(); $sleep = 1; } $this->sleep($sleep); } while (!$this->shouldExit()); } }