A list of Tasklets has failed during aggregation phase.
489082
@Private
  @Override
  public void aggregationThrewException(final List<Integer> taskletIds, final Exception exception) {
    try {
      failedTasklets(exception, taskletIds);
    } catch (final InterruptedException e) {
      throw new RuntimeException(e);
    }
  }
287116
protected void reportFatalError(TaskAttemptID id, Throwable throwable, 
                                  String logMsg) {
    LOG.fatal(logMsg);
    Throwable tCause = throwable.getCause();
    String cause = tCause == null 
                   ? StringUtils.stringifyException(throwable)
                   : StringUtils.stringifyException(tCause);
    try {
      umbilical.fatalError(id, cause);
    } catch (IOException ioe) {
      LOG.fatal("Failed to contact the tasktracker", ioe);
      System.exit(-1);
    }
  }
892207
private void submitFailureSlaEvent(Dataset dataset, String eventName) {
    try {
      CompactionSlaEventHelper.getEventSubmitterBuilder(dataset, Optional.<Job> absent(), this.fs)
      .eventSubmitter(this.eventSubmitter).eventName(eventName).build().submit();
    } catch (Throwable t) {
      LOG.warn("Failed to submit failure sla event:" + t, t);
    }
  }
1068709
synchronized void addTrackerTaskFailure(String trackerName,
                                          TaskTracker taskTracker,
                                          String lastFailureReason) {
    if (flakyTaskTrackers < (clusterSize * CLUSTER_BLACKLIST_PERCENT)) {
      String trackerHostName = convertTrackerNameToHostName(trackerName);

      List<String> trackerFailures = trackerToFailuresMap.get(trackerHostName);

      if (trackerFailures == null) {
        trackerFailures = new LinkedList<String>();
        trackerToFailuresMap.put(trackerHostName, trackerFailures);
      }
      trackerFailures.add(lastFailureReason);

      // Check if this tasktracker has turned 'flaky'
      if (trackerFailures.size() == maxTaskFailuresPerTracker) {
        ++flakyTaskTrackers;

        // Cancel reservations if appropriate
        if (taskTracker != null) {
          if (trackersReservedForMaps.containsKey(taskTracker)) {
            taskTracker.unreserveSlots(TaskType.MAP, this);
          }
          if (trackersReservedForReduces.containsKey(taskTracker)) {
            taskTracker.unreserveSlots(TaskType.REDUCE, this);
          }
        }
        LOG.info("TaskTracker at '" + trackerHostName + "' turned 'flaky'");
      }
    }
  }
797211
public void taskletFailed(final int taskletId, final Exception e) {
    final boolean aggregateOnCount;
    synchronized (stateLock) {
      failedTasklets.add(new ImmutablePair<>(taskletId, e));
      removePendingTaskletReferenceCount(taskletId);
      aggregateOnCount = aggregateOnCount();
    }

    if (aggregateOnCount) {
      aggregateTasklets(AggregateTriggerType.COUNT);
    }
  }
721774
private void failTasksWithMaxMemory(long memoryToRelease) {
    
    List<TaskAttemptID> allTasks = new ArrayList<TaskAttemptID>();
    allTasks.addAll(processTreeInfoMap.keySet());
    // Sort the tasks descendingly according to RSS memory usage 
    Collections.sort(allTasks, new Comparator<TaskAttemptID>() {
      @Override
      public int compare(TaskAttemptID tid1, TaskAttemptID tid2) {
        return  processTreeInfoMap.get(tid2).getMemoryUsed() >
                processTreeInfoMap.get(tid1).getMemoryUsed() ?
                1 : -1;
      }});
    
    long memoryReleased = 0;
    // Fail the tasks one by one until the memory requirement is met
    while (memoryReleased < memoryToRelease && !allTasks.isEmpty()) {
      TaskAttemptID tid = allTasks.remove(0);
      if (!isKillable(tid)) {
        continue;
      }
      long memoryUsed = processTreeInfoMap.get(tid).getMemoryUsed();
      if (memoryUsed == 0) {
        break; // Skip tasks without process tree information currently
      }
      tasksToKill.add(tid);
      memoryReleased += memoryUsed;
    }
    if (tasksToKill.isEmpty()) {
      LOG.error("The total memory usage is over CGroup limits. "
          + "But found no alive task to kill for freeing memory.");
    } else if (memoryReleased < memoryToRelease) {
      LOG.error("The total memory usage is over CGroup limits. "
          + "But uanble to find enough tasks to kill for freeing memory.");
    }
    killTasks();
  }
508247
public void incompleteSubTask(TaskAttemptID taskid, 
                                JobStatus jobStatus) {
    //
    // Note the failure and its location
    //
    TaskStatus status = taskStatuses.get(taskid);
    String trackerName;
    String trackerHostName = null;
    TaskStatus.State taskState = TaskStatus.State.FAILED;
    if (status != null) {
      trackerName = status.getTaskTracker();
      trackerHostName = 
        JobInProgressTraits.convertTrackerNameToHostName(trackerName);
      // Check if the user manually KILLED/FAILED this task-attempt...
      Boolean shouldFail = tasksToKill.remove(taskid);
      if (shouldFail != null) {
        if (status.getRunState() == TaskStatus.State.FAILED ||
            status.getRunState() == TaskStatus.State.KILLED) {
          taskState = (shouldFail) ? TaskStatus.State.FAILED :
                                     TaskStatus.State.KILLED;
        } else {
          taskState = (shouldFail) ? TaskStatus.State.FAILED_UNCLEAN :
                                     TaskStatus.State.KILLED_UNCLEAN;
          
        }
        status.setRunState(taskState);
        addDiagnosticInfo(taskid, "Task has been " + taskState + " by the user" );
      }
 
      taskState = status.getRunState();
      if (taskState != TaskStatus.State.FAILED && 
          taskState != TaskStatus.State.KILLED &&
          taskState != TaskStatus.State.FAILED_UNCLEAN &&
          taskState != TaskStatus.State.KILLED_UNCLEAN) {
        LOG.info("Task '" + taskid + "' running on '" + trackerName + 
                "' in state: '" + taskState + "' being failed!");
        status.setRunState(TaskStatus.State.FAILED);
        taskState = TaskStatus.State.FAILED;
      }

      // tasktracker went down and failed time was not reported. 
      if (0 == status.getFinishTime()){
        status.setFinishTime(JobTracker.getClock().getTime());
      }
    }

    this.activeTasks.remove(taskid);
    
    // Since we do not fail completed reduces (whose outputs go to hdfs), we 
    // should note this failure only for completed maps, only if this taskid;
    // completed this map. however if the job is done, there is no need to 
    // manipulate completed maps
    if (this.isMapTask() && !jobSetup && !jobCleanup && isComplete(taskid) && 
        jobStatus.getRunState() != JobStatus.SUCCEEDED) {
      this.completes--;
      
      // Reset the successfulTaskId since we don't have a SUCCESSFUL task now
      resetSuccessfulTaskid();
    }

    // Note that there can be failures of tasks that are hosted on a machine 
    // that has not yet registered with restarted jobtracker
    // recalculate the counts only if its a genuine failure
    if (tasks.contains(taskid)) {
      if (taskState == TaskStatus.State.FAILED) {
        numTaskFailures++;
        machinesWhereFailed.add(trackerHostName);
        if(maxSkipRecords>0) {
          //skipping feature enabled
          LOG.debug("TaskInProgress adding" + status.getNextRecordRange());
          failedRanges.add(status.getNextRecordRange());
          skipping = startSkipping();
        }

      } else if (taskState == TaskStatus.State.KILLED) {
        numKilledTasks++;
      }
    }

    if (numTaskFailures >= maxTaskAttempts) {
      LOG.info("TaskInProgress " + getTIPId() + " has failed " + numTaskFailures + " times.");
      kill();
    }
  }
1197306
private void failPendingCommands() {
    for (RaftSession session : raft.getSessions().getSessions()) {
      for (PendingCommand command : session.clearCommands()) {
        command.future().complete(logResponse(CommandResponse.builder()
            .withStatus(RaftResponse.Status.ERROR)
            .withError(RaftError.Type.COMMAND_FAILURE, "Request sequence number " + command.request().sequenceNumber() + " out of sequence")
            .withLastSequence(session.getRequestSequence())
            .build()));
      }
    }
  }
106322
private void failTask(Throwable cause)
    {
        TaskStatus taskStatus = getTaskStatus();
        if (!taskStatus.getState().isDone()) {
            log.debug(cause, "Remote task %s failed with %s", taskStatus.getSelf(), cause);
        }

        abort(failWith(getTaskStatus(), FAILED, ImmutableList.of(toFailure(cause))));
    }
614372
synchronized Map<String, List<String>> getTaskTrackerErrors() {
    // Clone the 'trackerToFailuresMap' and return the copy
    Map<String, List<String>> trackerErrors =
      new TreeMap<String, List<String>>(trackerToFailuresMap);
    return trackerErrors;
  }
182293
def on_error(self, subtask: Greenlet):
        
        log.error(
            'Runnable subtask died!',
            this=self,
            running=bool(self),
            subtask=subtask,
            exc=subtask.exception,
        )
        if not self.greenlet:
            return
        self.greenlet.kill(subtask.exception)
617969
@Override
  public void onFailedTask() {
    LOG.entering("TaskNodeImpl", "onFailedTask", getQualifiedName());
    if (!running.compareAndSet(true, false)) {
      LOG.fine(getQualifiedName() + "Trying to set failed on an already failed task. Something fishy!!!");
      LOG.exiting("TaskNodeImpl", "onFailedTask", getQualifiedName() +
          "Trying to set failed on an already failed task. Something fishy!!!");
      return;
    }
    taskNodeStatus.clearStateAndReleaseLocks();
    LOG.finest(getQualifiedName() + "Changed status to failed.");
    LOG.finest(getQualifiedName() + "Resetting topoSetupSent to false");
    topoSetupSent.set(false);
    if (parent != null && parent.isRunning()) {
      parent.onChildDead(taskId);
    } else {
      LOG.finest(getQualifiedName() + "Skipping asking parent to process child death");
    }
    for (final TaskNode child : children) {
      if (child.isRunning()) {
        child.onParentDead();
      }
    }
    final int newVersion = this.version.incrementAndGet();
    LOG.finest(getQualifiedName() + "Bumping up to version-" + newVersion);
    LOG.exiting("TaskNodeImpl", "onFailedTask", getQualifiedName());
  }
542654
private void setTaskFailed(String reason) {
        m_taskRecord.setProperty(TaskRecord.PROP_EXECUTOR, m_hostID);
        m_taskRecord.setProperty(TaskRecord.PROP_FINISH_TIME, Long.toString(System.currentTimeMillis()));
        m_taskRecord.setProperty(TaskRecord.PROP_FAIL_REASON, reason);
        m_taskRecord.setStatus(TaskStatus.FAILED);
        TaskManagerService.instance().updateTaskStatus(m_tenant, m_taskRecord, true);
    }
984611
function taskFileMain(argv)
{
    if( argv === undefined ) argv = process.argv

    const [options, args, helpText] = CLI.taskFileParse(argv);
    const collection = getTasksFromTaskfile();

    const p = loadPackageJson();
    if( tryShowVersion(options, p.version) )
        return;
    if( tryShowTasks(options, collection) )
        return;
    if( tryShowHelp(options, helpText) )
        return;

    tryRunTask(args, collection);
}
40836
function list(tasks) {
    return function continuable(callback) {
        var result = []
        var count = 0

        if (tasks.length === 0) {
            return callback(null, result)
        }

        tasks.forEach(function invokeSource(source, index) {
            source(function continuation(err, value) {
                if (err && result) {
                    result = null
                    callback(err)
                } else if (!err && result) {
                    result[index] = value
                    if (++count === tasks.length) {
                        callback(null, result)
                    }
                }
            })
        })
    }
}
1283691
public void errorFuture(UUID taskId, Exception e) {
        DistributedFuture<GROUP, Serializable> future = remove(taskId);
        if(future != null) {
            future.setException(e);
        }
    }
939119
@Override
  public Optional<String> trySchedule(final Tasklet tasklet) {
    for (int i = 0; i < idList.size(); i++) {
      final int index = (nextIndex + i) % idList.size();
      final String workerId = idList.get(index);
      
      if (idLoadMap.get(workerId) < workerCapacity) {
        nextIndex = (index + 1) % idList.size();
        return Optional.of(workerId);
      }
    }
    return Optional.empty();
  }