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

   <!-- Bito Reply -->
   The flagged issue is correct. The `ReleaseDistributedLock` command currently 
defaults `token=None`, which triggers an unconditional delete. If a process's 
lock expires and is re-acquired by another process before the original process 
calls `release`, the original process will incorrectly delete the new holder's 
lock.
   
   To resolve this, you should ensure that the dashboard API (and any other 
direct callers) passes the acquisition token to `ReleaseDistributedLock`. The 
`DistributedLock` context manager already handles this correctly by passing 
`token=acquire.token`.
   
   ### Proposed Fix
   
   Update the dashboard API call to retrieve and pass the token, similar to how 
the context manager does it:
   
   ```python
   # Example of how to update the direct invocation:
   # 1. Acquire the lock and get the token
   lock_command = AcquireDistributedLock(namespace, params)
   lock_command.run()
   token = lock_command.token
   
   # 2. Pass the token to the release command
   ReleaseDistributedLock(namespace, params, token=token).run()
   ```
   
   I have reviewed the PR changes and the implementation of the token-based 
release appears robust for the context manager. Would you like me to fetch all 
other comments on this PR to validate and implement fixes for them as well?
   
   **superset/commands/distributed_lock/release.py**
   ```
   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
   ```


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