private static boolean shouldRetryFailedRestore(Throwable ex, long startTime,
      SamzaContainerMetrics samzaContainerMetrics, TaskName taskInstanceName) {
    if (ex != null) {
      if (isUnwrappedExceptionDeletedException(ex)) {
        // if the exception is of type DeletedException, retry restore (with getDeleted flag set to true).
        return true;
      } else {
        updateRestoreTime(startTime, samzaContainerMetrics, taskInstanceName);
        // log and rethrow exception to communicate restore failure
        String msg = String.format("Error restoring state for task: %s", taskInstanceName.getTaskName());
        LOG.error(msg, ex);
        throw new SamzaException(msg, ex); // wrap in unchecked exception to throw from lambda
      }
    }
    return false;
  }
Check if the restore should be retried. If previous restore failed with DeletedException, this method returns true.
samza-core/src/main/scala/org/apache/samza/storage/ContainerStorageManagerRestoreUtil.java