This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new c9ff09a418 fix: Nested transaction is inactive when embedding
dashboard (#30699)
c9ff09a418 is described below
commit c9ff09a41831fcc3af207cf151dd72332efdb65b
Author: Michael S. Molina <[email protected]>
AuthorDate: Thu Oct 24 13:08:55 2024 -0300
fix: Nested transaction is inactive when embedding dashboard (#30699)
---
superset/cachekeys/api.py | 5 +++--
superset/dashboards/api.py | 19 +++++++++++--------
2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/superset/cachekeys/api.py b/superset/cachekeys/api.py
index 093d81b1c3..365b79c423 100644
--- a/superset/cachekeys/api.py
+++ b/superset/cachekeys/api.py
@@ -114,8 +114,8 @@ class CacheRestApi(BaseSupersetModelRestApi):
CacheKey.cache_key.in_(cache_keys)
)
- with db.session.begin_nested():
- db.session.execute(delete_stmt)
+ db.session.execute(delete_stmt)
+ db.session.commit() # pylint:
disable=consider-using-transaction
stats_logger_manager.instance.gauge(
"invalidated_cache", len(cache_keys)
@@ -126,6 +126,7 @@ class CacheRestApi(BaseSupersetModelRestApi):
len(datasource_uids),
)
except SQLAlchemyError as ex: # pragma: no cover
+ db.session.rollback() # pylint:
disable=consider-using-transaction
logger.error(ex, exc_info=True)
return self.response_500(str(ex))
return self.response(201)
diff --git a/superset/dashboards/api.py b/superset/dashboards/api.py
index a9191abacf..733cc555a4 100644
--- a/superset/dashboards/api.py
+++ b/superset/dashboards/api.py
@@ -1125,9 +1125,11 @@ class DashboardRestApi(BaseSupersetModelRestApi):
logger.info("Triggering screenshot ASYNC")
cache_dashboard_screenshot.delay(
username=get_current_user(),
- guest_token=g.user.guest_token
- if get_current_user() and isinstance(g.user, GuestUser)
- else None,
+ guest_token=(
+ g.user.guest_token
+ if get_current_user() and isinstance(g.user, GuestUser)
+ else None
+ ),
dashboard_id=dashboard.id,
dashboard_url=dashboard_url,
cache_key=cache_key,
@@ -1595,15 +1597,16 @@ class DashboardRestApi(BaseSupersetModelRestApi):
try:
body = self.embedded_config_schema.load(request.json)
- with db.session.begin_nested():
- embedded = EmbeddedDashboardDAO.upsert(
- dashboard,
- body["allowed_domains"],
- )
+ embedded = EmbeddedDashboardDAO.upsert(
+ dashboard,
+ body["allowed_domains"],
+ )
+ db.session.commit() # pylint: disable=consider-using-transaction
result = self.embedded_response_schema.dump(embedded)
return self.response(200, result=result)
except ValidationError as error:
+ db.session.rollback() # pylint: disable=consider-using-transaction
return self.response_400(message=error.messages)
@expose("/<id_or_slug>/embedded", methods=("DELETE",))