sadpandajoe commented on code in PR #35800:
URL: https://github.com/apache/superset/pull/35800#discussion_r2475481485
##########
superset/commands/report/execute.py:
##########
@@ -177,19 +177,34 @@ def create_log(self, error_message: Optional[str] = None)
-> None:
"""
Creates a Report execution log, uses the current computed last_value
for Alerts
"""
- log = ReportExecutionLog(
- scheduled_dttm=self._scheduled_dttm,
- start_dttm=self._start_dttm,
- end_dttm=datetime.utcnow(),
- value=self._report_schedule.last_value,
- value_row_json=self._report_schedule.last_value_row_json,
- state=self._report_schedule.last_state,
- error_message=error_message,
- report_schedule=self._report_schedule,
- uuid=self._execution_id,
- )
- db.session.add(log)
- db.session.commit() # pylint: disable=consider-using-transaction
+ from sqlalchemy.orm.exc import StaleDataError
+
+ try:
+ log = ReportExecutionLog(
+ scheduled_dttm=self._scheduled_dttm,
+ start_dttm=self._start_dttm,
+ end_dttm=datetime.utcnow(),
+ value=self._report_schedule.last_value,
+ value_row_json=self._report_schedule.last_value_row_json,
+ state=self._report_schedule.last_state,
+ error_message=error_message,
+ report_schedule=self._report_schedule,
+ uuid=self._execution_id,
+ )
+ db.session.add(log)
+ db.session.commit() # pylint: disable=consider-using-transaction
+ except StaleDataError as ex:
Review Comment:
The new StaleDataError handling isn’t covered by tests—could we add a
scheduler test that mocks db.session.commit to raise StaleDataError and asserts
we surface ReportScheduleUnexpectedError while leaving the original cause
intact?
--
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]