code: @VisibleForTesting
      void rollbackTasks(String workflowId, List<Task> createdTasks) {
          String description = "rolling back task from DAO for " + workflowId;
          String operation = "rollbackTasks";
  
          try {
              // rollback all newly created tasks in the workflow
              createdTasks.forEach(task -> new RetryUtil<>().retryOnException(() ->
              {
                  if (task.getTaskType().equals(SUB_WORKFLOW.name())) {
                      executionDAOFacade.removeWorkflow((String) task.getOutputData().get(SUB_WORKFLOW_ID), false);
                  }
                  executionDAOFacade.removeTask(task.getTaskId());
                  return null;
              }, null, null, 3, description, operation));
          } catch (Exception e) {
              String errorMsg = String.format("Error scheduling/rolling back tasks for workflow: %s", workflowId);
              LOGGER.error(errorMsg, e);
              throw new TerminateWorkflowException(errorMsg);
          }
      }
docs: Rolls back all newly created tasks in a workflow, essentially resetting the workflow state, in case of an exception during task creation or task enqueuing.
  
  @param createdTasks a {@link List} of newly created tasks in the workflow which are to be rolled back