bito-code-review[bot] commented on PR #43523:
URL: https://github.com/apache/superset/pull/43523#issuecomment-5414778132

   <!-- Bito Reply -->
   The flagged issue regarding a race condition in `cache_dashboard_screenshot` 
is correct. When multiple concurrent requests observe a stale `UPDATED` 
payload, they all independently trigger the Celery task because the distributed 
lock is only acquired inside the task itself, not before enqueueing.
   
   To resolve this, you should implement an atomic check-and-set (or mark as 
`PENDING`) in the cache before calling `.delay()`. This ensures only the first 
request triggers the task.
   
   Would you like me to implement this fix for you? I can also check the other 
comments on this PR and implement fixes for them if you wish.
   
   **superset/dashboards/api.py**
   ```
   if cache_payload.should_trigger_task(
               force,
               expected_scope=f"dashboard:{dashboard.id}",
               
check_updated_staleness=screenshot_obj.supports_updated_staleness,
           ):
               # TODO: Atomically mark as PENDING here to prevent race condition
               logger.info("Triggering screenshot ASYNC")
               cache_dashboard_screenshot.delay(
                   dashboard_id=dashboard.id,
                   force=force,
               )
   ```


-- 
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