You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2019/09/06 03:47:00 UTC

[jira] [Commented] (AIRFLOW-5417) Webserver won't start with long DagBag parsing

    [ https://issues.apache.org/jira/browse/AIRFLOW-5417?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16923906#comment-16923906 ] 

ASF GitHub Bot commented on AIRFLOW-5417:
-----------------------------------------

KevinYang21 commented on pull request #6023: [AIRFLOW-5417] Fix DB disconnects during webserver startup
URL: https://github.com/apache/airflow/pull/6023
 
 
   Make sure you have checked _all_ steps below.
   
   ### Jira
   
   - [x] My PR addresses the following [Airflow Jira](https://issues.apache.org/jira/browse/AIRFLOW/) issues and references them in the PR title. For example, "\[AIRFLOW-XXX\] My Airflow PR"
     - https://issues.apache.org/jira/browse/AIRFLOW-5417
   
   ### Description
   
   - [x] Here are some details about my PR, including screenshots of any UI changes:
   The current workflow of creating an app in views.py is:
   
   1. Create one DB session
   2. Assign it to flask-appbuilder, use the session to help initializing the app.
   3. Create DagBag
   4. **Reuse the same session** to add permission using flask-appbuilder etc.
       - Reason for us reusing the session is because we use the `scoped_session` w/o a scope function, thus made the session a [thread-local scope session](https://docs.sqlalchemy.org/en/13/orm/contextual.html#thread-local-scope), which will be reused until it is removed. Unfortunately flask-appbuilder doesn't remove the session after a query, [e.g. 1](https://github.com/dpgaspar/Flask-AppBuilder/blob/master/flask_appbuilder/security/sqla/manager.py#L371).
   
   Problem with this is that if during step 3, there's a DB disconnect, step 4 will fail because the session is still attached with the disconnected DB connection and not rolled back. It becomes a bigger problem if step 3 regularly takes a long time, more than the DB connection expire time, step 4 will always fail, which is the case for us currently.
   
   Another short-term approach is to remove the old session after DagBag creation. If moving the import to another scope is not appropriate, we can just do that, just one additional DB connection shouldn't be too much overhead.
   
   ### Tests
   
   - [x] My PR adds the following unit tests __OR__ does not need testing for this extremely good reason:
   Not really changing the behavior.
   
   ### Commits
   
   - [x] My commits all reference Jira issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Documentation
   
   - [ ] In case of new functionality, my PR adds documentation that describes how to use it.
     - All the public functions and the classes in the PR contain docstrings that explain what it does
     - If you implement backwards incompatible changes, please leave a note in the [Updating.md](https://github.com/apache/airflow/blob/master/UPDATING.md) so we can assign it to a appropriate release
   
 
----------------------------------------------------------------
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


> Webserver won't start with long DagBag parsing
> ----------------------------------------------
>
>                 Key: AIRFLOW-5417
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-5417
>             Project: Apache Airflow
>          Issue Type: Improvement
>          Components: webserver
>    Affects Versions: 1.10.5
>            Reporter: Kevin Yang
>            Assignee: Kevin Yang
>            Priority: Major
>
> When DB disconnect during DagBag creation, webserver will fail to start. This becomes a big issue when DagBag is large enough that creating it takes more time than DB server side connection expire limit. As it will fail webserver start up determinisitically.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)