You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/12/04 21:09:16 UTC

[GitHub] [airflow] SamWheating opened a new pull request #12822: Removing redundant calls to session.commit()

SamWheating opened a new pull request #12822:
URL: https://github.com/apache/airflow/pull/12822


   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of existing issue, reference it using one of the following:
   
   closes: https://github.com/apache/airflow/issues/12818
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   Re: https://github.com/apache/airflow/issues/12818
   
   Removing redundant calls to `session.commit()` in places where the commit / rollback is already handled by a wrapping function or context manager. 
   
   I only removed commits in places where:
    - the session was provided by `provide_session()` or `create_session()`
    - the commit in question was closely followed by a `return` or end of function
   
   As I wanted to avoid modifying the functionality of any code.
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   


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

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



[GitHub] [airflow] uranusjr commented on a change in pull request #12822: Removing redundant calls to session.commit()

Posted by GitBox <gi...@apache.org>.
uranusjr commented on a change in pull request #12822:
URL: https://github.com/apache/airflow/pull/12822#discussion_r643024863



##########
File path: airflow/jobs/base_job.py
##########
@@ -246,7 +246,6 @@ def run(self):
             finally:
                 self.end_date = timezone.utcnow()
                 session.merge(self)
-                session.commit()

Review comment:
       Is it? The context manager only commits when exited successfully (rollbacks on an exception). This commit also saves changes on an exception.




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

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



[GitHub] [airflow] SamWheating commented on pull request #12822: Removing redundant calls to session.commit()

Posted by GitBox <gi...@apache.org>.
SamWheating commented on pull request #12822:
URL: https://github.com/apache/airflow/pull/12822#issuecomment-742099715


   > We might need session.flush() at few places. This is because the wrapper does not commit if the session is passed to the function.
   
   Having re-read `airflow/utils/session.py` I now see what you mean. I'll have to revisit this and look a little more closely. I'll push an update by EOD friday after which this will be ready for review. 


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

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



[GitHub] [airflow] SamWheating commented on pull request #12822: Removing redundant calls to session.commit()

Posted by GitBox <gi...@apache.org>.
SamWheating commented on pull request #12822:
URL: https://github.com/apache/airflow/pull/12822#issuecomment-821091046


   I'm on it - sorry for taking so long, this one keeps falling of my radar somehow.


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

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



[GitHub] [airflow] ashb commented on pull request #12822: Removing redundant calls to session.commit()

Posted by GitBox <gi...@apache.org>.
ashb commented on pull request #12822:
URL: https://github.com/apache/airflow/pull/12822#issuecomment-739155042


   Yeah, is probably say the default is to replace it with a 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.

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



[GitHub] [airflow] github-actions[bot] commented on pull request #12822: Removing redundant calls to session.commit()

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #12822:
URL: https://github.com/apache/airflow/pull/12822#issuecomment-787209760


   This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.


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

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



[GitHub] [airflow] github-actions[bot] commented on pull request #12822: Removing redundant calls to session.commit()

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #12822:
URL: https://github.com/apache/airflow/pull/12822#issuecomment-820817372


   This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.


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

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



[GitHub] [airflow] github-actions[bot] commented on pull request #12822: Removing redundant calls to session.commit()

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #12822:
URL: https://github.com/apache/airflow/pull/12822#issuecomment-851727555


   This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.


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

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



[GitHub] [airflow] github-actions[bot] commented on pull request #12822: Removing redundant calls to session.commit()

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #12822:
URL: https://github.com/apache/airflow/pull/12822#issuecomment-749254660


   The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest master at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.


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

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



[GitHub] [airflow] SamWheating commented on a change in pull request #12822: Removing redundant calls to session.commit()

Posted by GitBox <gi...@apache.org>.
SamWheating commented on a change in pull request #12822:
URL: https://github.com/apache/airflow/pull/12822#discussion_r541322616



##########
File path: airflow/jobs/base_job.py
##########
@@ -246,7 +246,6 @@ def run(self):
             finally:
                 self.end_date = timezone.utcnow()
                 session.merge(self)
-                session.commit()

Review comment:
       this one is safe to remove since its the last line within a create_session context manager, so the commit is happening right after this anyways. 




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

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



[GitHub] [airflow] SamWheating commented on pull request #12822: Removing redundant calls to session.commit()

Posted by GitBox <gi...@apache.org>.
SamWheating commented on pull request #12822:
URL: https://github.com/apache/airflow/pull/12822#issuecomment-787978445


   My bad - I forgot about this PR over the holidays. I can rebase and fix this up in the next few days as the issue is still open. 


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

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



[GitHub] [airflow] ashb commented on pull request #12822: Removing redundant calls to session.commit()

Posted by GitBox <gi...@apache.org>.
ashb commented on pull request #12822:
URL: https://github.com/apache/airflow/pull/12822#issuecomment-821017415


   @SamWheating Would you like one of us to finish of this PR for you?


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

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



[GitHub] [airflow] github-actions[bot] closed pull request #12822: Removing redundant calls to session.commit()

Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed pull request #12822:
URL: https://github.com/apache/airflow/pull/12822


   


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

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



[GitHub] [airflow] SamWheating commented on a change in pull request #12822: Removing redundant calls to session.commit()

Posted by GitBox <gi...@apache.org>.
SamWheating commented on a change in pull request #12822:
URL: https://github.com/apache/airflow/pull/12822#discussion_r646947662



##########
File path: airflow/jobs/base_job.py
##########
@@ -246,7 +246,6 @@ def run(self):
             finally:
                 self.end_date = timezone.utcnow()
                 session.merge(self)
-                session.commit()

Review comment:
       Good catch, I'll add this one back in. 




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

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