alexandrusoare commented on code in PR #42481:
URL: https://github.com/apache/superset/pull/42481#discussion_r3681671443


##########
superset/commands/report/execute.py:
##########
@@ -1224,6 +1321,70 @@ def next(self) -> None:  # noqa: C901
             if isinstance(first_ex, SupersetErrorsException):
                 error_message = ";".join([error.message for error in 
first_ex.errors])
 
+            # --- Retry logic ---
+            retry_on_failure: bool = self._report_schedule.retry_on_failure
+            max_attempts: int = self._report_schedule.retry_max_attempts
+
+            # If a new crontab window has fired since the first failure, reset 
the
+            # retry counter so this window gets a fresh budget.
+            if retry_on_failure and self._is_retry_window_stale():
+                self._reset_retry_counter()
+
+            current_attempt = self._report_schedule.retry_attempt
+
+            # If this execution was itself a retry (current_attempt > 0),
+            # send the retry-failure notification *after* the attempt ran so
+            # the email reflects what happened, not what is about to be
+            # scheduled.  ("You will receive an update after each retry.")
+            if retry_on_failure and current_attempt > 0:
+                try:
+                    self.send_retry_notification(
+                        current_attempt, max_attempts, error_message
+                    )
+                except Exception:  # pylint: disable=broad-except
+                    logger.warning(
+                        "Failed to send retry notification for report schedule 
"
+                        "(execution %s)",
+                        self._execution_id,
+                        exc_info=True,
+                    )
+
+            if retry_on_failure and current_attempt < max_attempts:
+                # Schedule another attempt and exit cleanly (don't re-raise).
+                self._increment_retry()
+                try:
+                    self.update_report_schedule_and_log(
+                        ReportState.RETRYING, error_message=error_message
+                    )
+                except ReportScheduleUnexpectedError as logging_ex:
+                    logger.warning(
+                        "Failed to log RETRYING state for report schedule "
+                        "(execution %s) due to database issue",
+                        self._execution_id,
+                        exc_info=True,
+                    )
+                    raise first_ex from logging_ex
+                self._schedule_retry(

Review Comment:
   done!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to