Restarts failed tasks of a job.
352651
def retry(self):
        

        logger.info('Job {0} retrying all failed tasks'.format(self.name))
        self.initialize_snapshot()

        failed_task_names = []
        for task_name, log in self.run_log['tasks'].items():
            if log.get('success', True) == False:
                failed_task_names.append(task_name)

        if len(failed_task_names) == 0:
            raise DagobahError('no failed tasks to retry')

        self._set_status('running')
        self.run_log['last_retry_time'] = datetime.utcnow()

        logger.debug('Job {0} seeding run logs'.format(self.name))
        for task_name in failed_task_names:
            self._put_task_in_run_log(task_name)
            self.tasks[task_name].start()

        self._commit_run_log()
255499
private void failedTasklets(final Exception exception, final List<Integer> taskletIds)
      throws InterruptedException {

    final List<TInput> inputs = getInputs(taskletIds);
    final AggregateResult failure = new AggregateResult(exception, inputs);

    if (callbackHandler != null) {
      executor.execute(new Runnable() {
        @Override
        public void run() {
          callbackHandler.onFailure(new VortexAggregateException(exception, inputs));
        }
      });
    }

    resultQueue.put(new ImmutablePair<>(taskletIds, failure));
  }
1078971
public synchronized void failJob(JobInProgress job) {
    if (null == job) {
      LOG.info("Fail on null job is not valid");
      return;
    }

    JobStatus prevStatus = (JobStatus)job.getStatus().clone();
    LOG.info("Failing job " + job.getJobID());
    job.fail();

    // Inform the listeners if the job state has changed
    JobStatus newStatus = (JobStatus)job.getStatus().clone();
    if (prevStatus.getRunState() != newStatus.getRunState()) {
      JobStatusChangeEvent event =
        new JobStatusChangeEvent(job, EventType.RUN_STATE_CHANGED, prevStatus,
            newStatus);
      updateJobInProgressListeners(event);
    }
  }
911272
public function fail($e = null)
    {
        $this->markAsFailed();

        if ($this->isDeleted()) {
            return;
        }

        try {
            // If the job has failed, we will delete it, call the "failed" method and then call
            // an event indicating the job has failed so it can be logged if needed. This is
            // to allow every developer to better keep monitor of their failed queue jobs.
            $this->delete();

            $this->failed($e);
        } finally {
            $this->resolve(Dispatcher::class)->dispatch(new JobFailed(
                $this->connectionName, $this, $e ?: new ManuallyFailedException
            ));
        }
    }
409091
protected function shouldBeFailed(): bool
    {
        if ($this->attempts() > 3 && $this->job) {
            $this->fail(null);

            return true;
        }

        return false;
    }
1370702
protected void initFailedJobCommandFactory() {
    if (failedJobCommandFactory == null) {
      failedJobCommandFactory = new DefaultFailedJobCommandFactory();
    }
    if (postParseListeners == null) {
      postParseListeners = new ArrayList<BpmnParseListener>();
    }
    postParseListeners.add(new DefaultFailedJobParseListener());

  }
1202985
protected function failedJob(Job $job, \Throwable $exception, bool $internal): void
    {
        if ($this->logger) {
            $context = [
                'name' => $job->getName(),
                'arguments' => $job->getArguments(),
                'message' => $exception->getMessage(),
                'retryable' => !$exception instanceof UnrecoverableJobExceptionInterface,
                'internal' => $internal,
            ];
            if (($p = $exception->getPrevious())) {
                $context['cause'] = $p->getMessage();
            }
            $this->logger->error('Job failed.', $context);
        }
        if ($this->eventDispatcher) {
            $this->eventDispatcher->dispatch(self::JOB_FAILED_EVENT, new FailedJobEvent($job, $exception, $internal));
        }
        if ($this->triggerBatchEvents) {
            $batch = new JobBatch([$job]);
            $batch->next();
            $batch->result($exception);
            $this->finishBatch($batch);
        }
    }
707649
public boolean restartJob(int containerIndex) {
    synchronized (this) {
      if (isTerminated) {
        LOG.severe("Job has been killed");
        return false;
      }

      // List of tasks to restart
      List<String> tasksToRestart = new ArrayList<>();
      if (containerIndex == -1) {
        // Restart all tasks
        tasksToRestart.addAll(tasksId.values());
      } else {
        tasksToRestart.add(tasksId.get(containerIndex));
      }

      // Kill the task -- the framework will automatically restart it
      for (String taskId : tasksToRestart) {
        driver.killTask(Protos.TaskID.newBuilder().setValue(taskId).build());
      }

      return true;
    }
  }
489816
private void restart(long globalModVersionOfFailover) {
		try {
			if (transitionState(JobStatus.CREATED, JobStatus.RUNNING)) {
				// if we have checkpointed state, reload it into the executions
				if (executionGraph.getCheckpointCoordinator() != null) {
					// we restart the checkpoint scheduler for
					// i) enable new checkpoint could be triggered without waiting for last checkpoint expired.
					// ii) ensure the EXACTLY_ONCE semantics if needed.
					executionGraph.getCheckpointCoordinator().abortPendingCheckpoints(
						new CheckpointException(CheckpointFailureReason.JOB_FAILOVER_REGION));

					executionGraph.getCheckpointCoordinator().restoreLatestCheckpointedState(
						tasks, false, true);
				}

				HashSet<AllocationID> previousAllocationsInRegion = new HashSet<>(connectedExecutionVertexes.size());
				for (ExecutionVertex connectedExecutionVertex : connectedExecutionVertexes) {
					AllocationID latestPriorAllocation = connectedExecutionVertex.getLatestPriorAllocation();
					if (latestPriorAllocation != null) {
						previousAllocationsInRegion.add(latestPriorAllocation);
					}
				}

				//TODO, use restart strategy to schedule them.
				//restart all connected ExecutionVertexes
				for (ExecutionVertex ev : connectedExecutionVertexes) {
					try {
						ev.scheduleForExecution(
							executionGraph.getSlotProvider(),
							executionGraph.isQueuedSchedulingAllowed(),
							LocationPreferenceConstraint.ANY,
							previousAllocationsInRegion); // some inputs not belonging to the failover region might have failed concurrently
					}
					catch (Throwable e) {
						failover(globalModVersionOfFailover);
					}
				}
			}
			else {
				LOG.info("FailoverRegion {} switched from CREATED to RUNNING fail, will fail this region again.", id);
				failover(globalModVersionOfFailover);
			}
		} catch (Exception e) {
			LOG.info("FailoverRegion {} restart failed, failover again.", id, e);
			failover(globalModVersionOfFailover);
		}
	}
72312
def run_all
      passed, failed_examples, passed_examples = Runner.run(['spec'], options.merge({ :message => 'Run all specs'}))

      self.rerun_specs = failed_examples
      self.last_run_passed = passed

      throw :task_has_failed unless passed
    end
676617
public function restart()
    {
        $workersArgs = $this->ResqueStatus->getWorkers();

        $this->params['all'] = true;
        $this->stop();

        $this->out('<info>' . __d('cake_resque', 'Restarting workers') . '</info>');
        if (!empty($workersArgs)) {
            $debug = $this->params['debug'];
            $this->debug(__d('cake_resque', 'Found ' . count($workersArgs) . ' workers to restart'));

            foreach ($workersArgs as $workerArgs) {
                $workerArgs['debug'] = $debug;
                if (isset($workerArgs['type']) && $workerArgs['type'] === 'scheduler') {
                    $this->startScheduler($workerArgs);
                } else {
                    $this->start($workerArgs);
                }
            }
            $this->out('');
        } else {
            $this->out('<warning>' . __d('cake_resque', 'No active workers found, will start brand new worker') . '</warning>');
            $this->start();
        }
    }
1067567
def on_failure(self, exc, task_id, args, kwargs, einfo):
        
        log.error('[{}] failed due to {}'.format(task_id, getattr(einfo, 'traceback', None)))
        super(LoggedTask, self).on_failure(exc, task_id, args, kwargs, einfo)
181054
function jobDone(err, data) {
        // TODO: check if function was already called before

        // check if we close the connection after this (to prevent memory leaks)
        var closing = totalRequests > REQUESTS_BEFORE_WORKER_RESTART ? true : false;

        var msg = {};

        if (err) {
            msg.errMessage = err.message;
            msg.status = 'fail';
            closing = true; // always close the worker if any error happens
        } else {
            msg.status = 'success';
        }
        msg.data = data;
        msg.closing = closing;

        // send our data back to the master
        res.statusCode = 200;
        res.write(JSON.stringify(msg));
        res.close();

        // close this worker if necessary
        if (closing) {
            phantom.exit();
        }
    }
361645
def restart(self, *args, **kw):
        """"""
        self.stop()
        self.start(*args, **kw)
754427
def on_failure(self, exc, task_id, args, kwargs, einfo):
        
        if not FailedTask.objects.filter(task_id=task_id, datetime_resolved=None).exists():
            FailedTask.objects.create(
                task_name=_truncate_to_field(FailedTask, 'task_name', self.name),
                task_id=task_id,  # Fixed length UUID: No need to truncate
                args=args,
                kwargs=kwargs,
                exc=_truncate_to_field(FailedTask, 'exc', repr(exc)),
            )
        super(PersistOnFailureTask, self).on_failure(exc, task_id, args, kwargs, einfo)
316002
private void initialize(Function<SqlTask, ?> onDone, CounterStat failedTasks)
    {
        requireNonNull(onDone, "onDone is null");
        requireNonNull(failedTasks, "failedTasks is null");
        taskStateMachine.addStateChangeListener(new StateChangeListener<TaskState>()
        {
            @Override
            public void stateChanged(TaskState newState)
            {
                if (!newState.isDone()) {
                    return;
                }

                // Update failed tasks counter
                if (newState == FAILED) {
                    failedTasks.update(1);
                }

                // store final task info
                while (true) {
                    TaskHolder taskHolder = taskHolderReference.get();
                    if (taskHolder.isFinished()) {
                        // another concurrent worker already set the final state
                        return;
                    }

                    if (taskHolderReference.compareAndSet(taskHolder, new TaskHolder(createTaskInfo(taskHolder), taskHolder.getIoStats()))) {
                        break;
                    }
                }

                // make sure buffers are cleaned up
                if (newState == FAILED || newState == ABORTED) {
                    // don't close buffers for a failed query
                    // closed buffers signal to upstream tasks that everything finished cleanly
                    outputBuffer.fail();
                }
                else {
                    outputBuffer.destroy();
                }

                try {
                    onDone.apply(SqlTask.this);
                }
                catch (Exception e) {
                    log.warn(e, "Error running task cleanup callback %s", SqlTask.this.taskId);
                }
            }
        });
    }
960867
public final void restartTask (final ITask task) throws ExecutionException {

        try {
            if (task != null) {
                if (task instanceof IOTask) {
                    executor.submit((IOTask) task);
                } else {
                    task.call();
                }
                taskBalancer.releaseConnection(outstandingTasks.get(task));
                outstandingTasks.remove(task);
            }
            LOGGER.debug("Restarted a Task out of the outstandingTasks Queue");
        } catch (Exception e) {
            throw new ExecutionException(e);
        }
    }