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

   <!-- Bito Reply -->
   The flagged issue correctly identifies a potential race condition in 
`superset/versioning/restore.py`. Because 
`chart_attachment_windows_for_dashboard` reads the association history from the 
database, a concurrent membership change could commit after the read but before 
the restore flush, leading to an inconsistent state.
   
   To resolve this, you should wrap the membership check and the subsequent 
restore flush in a database transaction that ensures isolation, or use a 
`SELECT ... FOR UPDATE` lock on the relevant dashboard or membership records if 
the database backend supports it. Given the context of 
`superset/versioning/restore.py`, ensuring the operation is atomic within the 
current session's transaction is the recommended approach.
   
   Would you like me to fetch all other comments on this PR to validate and 
implement fixes for them as well?
   
   **superset/versioning/restore.py**
   ```
   # Wrap in a transaction to ensure atomicity
       with db.session.begin_nested():
           member_ids = sorted(
               {
                   slice_id
                   for slice_id, window in 
chart_attachment_windows_for_dashboard(dashboard.id)
                   if window.contains(transaction_id)
               }
           )
           # ... proceed with restore flush ...
   ```


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