geido commented on code in PR #44144:
URL: https://github.com/apache/superset/pull/44144#discussion_r4037295771
##########
superset/dashboards/api.py:
##########
@@ -198,6 +203,10 @@
logger = logging.getLogger(__name__)
+SCREENSHOT_API_LOCK_NAMESPACE = "dashboard_screenshot_api"
+SCREENSHOT_API_LOCK_WAIT_SECONDS = 1.0
Review Comment:
Good catch — fixed in fe43f3552d. Contenders now wait through the producer
lock's configured lease, and the lock receives that same TTL, instead of using
an unrelated one-second cap. The enqueue-before-pointer ordering is unchanged,
so a failed broker publish still cannot advertise unaccepted work. The
red/green regression returns 503 on the old code and now joins the published
Pending key; in Docker, 12 simultaneous forced requests returned one 202 and
eleven 200s for one key, with no 503.
##########
superset/dashboards/api.py:
##########
@@ -1965,44 +1984,241 @@ def cache_dashboard_screenshot(self, pk: int,
**kwargs: Any) -> WerkzeugResponse
dashboard_url = get_url_path("Superset.dashboard_permalink",
key=permalink_key)
screenshot_obj = DashboardScreenshot(dashboard_url, dashboard.digest)
- cache_key = screenshot_obj.get_cache_key(window_size, thumb_size,
permalink_key)
- image_url = get_url_path(
- "DashboardRestApi.screenshot", pk=dashboard.id, digest=cache_key
- )
- cache_payload = (
- screenshot_obj.get_from_cache_key(cache_key) or
ScreenshotCachePayload()
+ cache_scope = f"dashboard:{dashboard.id}"
+ request_cache_key = screenshot_obj.get_api_request_cache_key(
+ window_size,
+ thumb_size,
+ permalink_key,
+ cache_scope,
)
- def build_response(status_code: int) -> WerkzeugResponse:
+ def build_response(
+ status_code: int,
+ cache_key: str,
+ cache_payload: ScreenshotCachePayload,
+ ) -> WerkzeugResponse:
return self.response(
status_code,
cache_key=cache_key,
dashboard_url=dashboard_url,
- image_url=image_url,
+ image_url=get_url_path(
+ "DashboardRestApi.screenshot",
+ pk=dashboard.id,
+ digest=cache_key,
+ ),
+ task_timeout_seconds=(
Review Comment:
I checked this and am keeping it out of this PR. already documents that it
must exceed the task's 300-second soft limit and defaults to 360 seconds. The
UI budget is , so it only expires before 300 seconds when TTL is below 150, not
for every value below 300. Enforcing invalid custom configurations, or coupling
this endpoint to a hard-coded task limit, is separate configuration-hardening
work; I called that boundary out in the PR description.
##########
superset-frontend/src/dashboard/hooks/useDownloadScreenshot.ts:
##########
@@ -134,17 +168,28 @@ export const useDownloadScreenshot = (
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
})
- .catch(err => {
+ .catch(async err => {
Review Comment:
This is real, but unchanged from master: this catch already swallows non-404
GET errors, so they do not increment retries in either version. This PR is
limited to recognizing terminal task metadata on the screenshot endpoint's 404
response. I documented the unchanged generic polling issue as an explicit scope
boundary rather than expanding this fix.
--
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]