codeant-ai-for-open-source[bot] commented on code in PR #43523:
URL: https://github.com/apache/superset/pull/43523#discussion_r3855945690
##########
superset/dashboards/api.py:
##########
@@ -1996,7 +1996,9 @@ def build_response(status_code: int) -> WerkzeugResponse:
)
if cache_payload.should_trigger_task(
- force, expected_scope=f"dashboard:{dashboard.id}"
+ force,
+ expected_scope=f"dashboard:{dashboard.id}",
+ check_updated_staleness=screenshot_obj.supports_updated_staleness,
Review Comment:
**Suggestion:** Enabling updated staleness causes every concurrent request
that observes the same stale `UPDATED` payload to enqueue
`cache_dashboard_screenshot` independently. The distributed lock is acquired
only after each Celery task starts, so it suppresses duplicate rendering but
does not prevent an unbounded number of duplicate tasks from accumulating in
the queue during a high-traffic refresh. Atomically claim the stale entry (for
example by marking it `PENDING` or using a cache-level compare-and-set) before
enqueueing. [race condition]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Concurrent dashboard requests enqueue redundant Celery tasks.
- ⚠️ Thumbnail workers spend capacity processing duplicate refreshes.
- ⚠️ Large refresh bursts can increase queue latency for screenshots.
```
</details>
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=ccc03633f8544c109012d530e42de36b&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=ccc03633f8544c109012d530e42de36b&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/dashboards/api.py
**Line:** 2001:2001
**Comment:**
*Race Condition: Enabling updated staleness causes every concurrent
request that observes the same stale `UPDATED` payload to enqueue
`cache_dashboard_screenshot` independently. The distributed lock is acquired
only after each Celery task starts, so it suppresses duplicate rendering but
does not prevent an unbounded number of duplicate tasks from accumulating in
the queue during a high-traffic refresh. Atomically claim the stale entry (for
example by marking it `PENDING` or using a cache-level compare-and-set) before
enqueueing.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43523&comment_hash=dca5cc2fcbab6a4de3e59cea6ccfeb9e5e33ef1cec94c66d1d9e85d924f5f812&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43523&comment_hash=dca5cc2fcbab6a4de3e59cea6ccfeb9e5e33ef1cec94c66d1d9e85d924f5f812&reaction=dislike'>👎</a>
--
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]