public void updateTask(TaskModel taskModel) {
        if (taskModel.getStatus() != null) {
            if (!taskModel.getStatus().isTerminal()
                    || (taskModel.getStatus().isTerminal() && taskModel.getUpdateTime() == 0)) {
                taskModel.setUpdateTime(System.currentTimeMillis());
            }
            if (taskModel.getStatus().isTerminal() && taskModel.getEndTime() == 0) {
                taskModel.setEndTime(System.currentTimeMillis());
            }
        }
        externalizeTaskData(taskModel);
        executionDAO.updateTask(taskModel);
        try {
            /*
             * Indexing a task for every update adds a lot of volume. That is ok but if async indexing
             * is enabled and tasks are stored in memory until a block has completed, we would lose a lot
             * of tasks on a system failure. So only index for each update if async indexing is not enabled.
             * If it *is* enabled, tasks will be indexed only when a workflow is in terminal state.
             */
            if (!properties.isAsyncIndexingEnabled()) {
                indexDAO.indexTask(new TaskSummary(taskModel.toTask()));
            }
        } catch (TerminateWorkflowException e) {
            // re-throw it so we can terminate the workflow
            throw e;
        } catch (Exception e) {
            String errorMsg =
                    String.format(
                            "Error updating task: %s in workflow: %s",
                            taskModel.getTaskId(), taskModel.getWorkflowInstanceId());
            LOGGER.error(errorMsg, e);
            throw new TransientException(errorMsg, e);
        }
    }
Sets the update time for the task. Sets the end time for the task (if task is in terminal
state and end time is not set). Updates the task in the {@link ExecutionDAO} first, then
stores it in the {@link IndexDAO}.

@param taskModel the task to be updated in the data store
@throws TransientException if the {@link IndexDAO} or {@link ExecutionDAO} operations fail.
@throws com.netflix.conductor.core.exception.NonTransientException if the externalization of
    payload fails.
core/src/main/java/com/netflix/conductor/core/dal/ExecutionDAOFacade.java