mikebridge commented on code in PR #45551:
URL: https://github.com/apache/superset/pull/45551#discussion_r4351254031
##########
superset/commands/dashboard/restore_version.py:
##########
@@ -43,3 +53,35 @@ class
RestoreDashboardVersionCommand(BaseRestoreVersionCommand):
not_found_exc = DashboardNotFoundError
forbidden_exc = DashboardForbiddenError
failed_exc = DashboardUpdateFailedError
+
+ def run(self) -> RestoreResult:
+ """Restore, confirming a reported chart-purge race before surfacing it.
+
+ The transaction has rolled back by the time the race reaches here,
+ so a fresh read sees the purge's commit. Only when one of the charts
+ whose membership the restore was changing is really gone is the
+ retryable :class:`ChartPurgedDuringRestoreError` raised. Otherwise,
+ or when the confirming read itself fails, the restore fails the
+ ordinary way.
+ """
+ try:
+ return super().run()
+ except ChartPurgedDuringRestoreError as ex:
+ slices: sa.Table = Slice.__table__
+ try:
+ remaining: set[int] = set(
+ db.session.execute(
+
sa.select(slices.c.id).where(slices.c.id.in_(ex.chart_ids))
Review Comment:
Thanks for flagging the identity edge. It's possible with SQLite's reused
maximum ROWID, or with explicitly reused IDs on PostgreSQL/MySQL. Normal
sequence and auto-increment allocation on PostgreSQL and InnoDB doesn't recycle
deleted IDs. The check at `restore_version.py:74-80` runs after rollback, so
even REPEATABLE READ doesn't hide a committed replacement: the user gets a 422
("Dashboard could not be updated"), and that request changes nothing.
I'm keeping the conservative fallback here. Changing only this check to a
409 would promise a safe retry while the retry still resolves membership by
integer ID, so UUID-aware membership reconstruction belongs in a separate
follow-up.
--
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]