You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/07/21 17:58:46 UTC

[GitHub] [superset] john-bodley opened a new pull request, #20811: fix: Ensure consistent rollback logic

john-bodley opened a new pull request, #20811:
URL: https://github.com/apache/superset/pull/20811

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   
   This PR ensures we consistently handle rollbacks when an error occurs. Throughout the code there's inconsistent logic of the form:
   
   ```python
   try:    
       if commit:
           db.session.commit()
   except SQLAlchemyError as ex:
       db.session.rollback()
   ```
   
   as well as:
   
   ```python
   try:    
       if commit:
           db.session.commit()
   except SQLAlchemyError as ex:
       if commit:
           db.session.rollback()
   ```
   
   This PR—by way of `git grep -B 1 rollback`—removes the unnecessary `if commit` checkout before a rollback because we want to rollback any operation which failed—pre commit—in the transaction regardless of whether we're planning to commit, i.e., save the state. 
   
   Regarding commits per [here](https://www.geeksforgeeks.org/difference-between-commit-and-rollback-in-sql/) it's worth noting that once committed a rollback is not viable.
   
   > The transaction can not undo changes after COMMIT execution.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   
   CI.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley merged pull request #20811: fix: Ensure consistent rollback logic for failed SQL operations

Posted by GitBox <gi...@apache.org>.
john-bodley merged PR #20811:
URL: https://github.com/apache/superset/pull/20811


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org