codeant-ai-for-open-source[bot] commented on code in PR #43462:
URL: https://github.com/apache/superset/pull/43462#discussion_r3844486814


##########
superset/commands/distributed_lock/release.py:
##########
@@ -37,19 +38,52 @@ class ReleaseDistributedLock(BaseDistributedLockCommand):
     """
     Release a distributed lock with automatic backend selection.
 
-    Uses Redis DELETE when DISTRIBUTED_COORDINATION_CONFIG is configured,
-    otherwise deletes from KeyValue table.
+    Uses Redis when DISTRIBUTED_COORDINATION_CONFIG is configured, otherwise 
the
+    KeyValue table. Release is **ownership-checked**: it only removes the lock 
if
+    the stored value still matches this acquisition's ``token``. Without that
+    check, a holder whose TTL expired (letting another holder acquire the same
+    key) would delete the *new* holder's lock on its own release.
     """
 
+    def __init__(
+        self,
+        namespace: str,
+        params: dict[str, Any] | None = None,
+        token: str | None = None,
+    ) -> None:
+        super().__init__(namespace, params)
+        # The acquisition token to match on release (see 
AcquireDistributedLock).
+        # None means "delete unconditionally" — only for callers that did not
+        # acquire via the token-aware path.
+        self.token = token

Review Comment:
   **Suggestion:** The default `token=None` path still performs an 
unconditional delete, and the dashboard API directly invokes this release after 
acquiring the lock without retaining or passing the acquisition token. If the 
enqueueing request's lock expires and another export acquires the same key 
before enqueue failure cleanup runs, this call deletes the newer holder's lock. 
Retain the token for same-process acquisition/cleanup paths; use an explicit 
separate mechanism for the cross-process Excel task handoff. [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Failed export enqueue cleanup can remove a newer export lock.
   - ⚠️ Concurrent exports can bypass dashboard/user throttling.
   - ⚠️ Affected path is the dashboard Excel export API.
   ```
   </details>
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/commands/distributed_lock/release.py
   **Line:** 58:58
   **Comment:**
        *Api Mismatch: The default `token=None` path still performs an 
unconditional delete, and the dashboard API directly invokes this release after 
acquiring the lock without retaining or passing the acquisition token. If the 
enqueueing request's lock expires and another export acquires the same key 
before enqueue failure cleanup runs, this call deletes the newer holder's lock. 
Retain the token for same-process acquisition/cleanup paths; use an explicit 
separate mechanism for the cross-process Excel task handoff.
   
   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%2F43462&comment_hash=c72c265ffcde3ca516df2c3f915680f434df97dddcdea162d60a042443a84890&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43462&comment_hash=c72c265ffcde3ca516df2c3f915680f434df97dddcdea162d60a042443a84890&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]

Reply via email to