-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix migration metadata lock on ab_view_menu #7417
Conversation
This fix is to make sure the scoped session created by the AppBuilder init code (that creates a bunch of roles and permissions) will be released and committed when the AppBuidler init code goes out of scope. Without running in a context, the code leaves the session open with a lock on ab_view_menu metadata, which prevents migration cefabc8f7d38_increase_size_of_name_column_in_ab_view from running an ALTER on that table. modified: superset/__init__.py
Since recently (FAB 2.0), FAB supports using the Flask application factory pattern http://flask.pocoo.org/docs/1.0/patterns/appfactories/ We should move to using this for obvious reasons. In the meantime, @dpgaspar (FAB creator/maintainer) what do you think about this? |
Ooops there's a conflict here. |
👍 we're seeing this issue too :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Craig was right. I made the change.
Hi, my |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue |
Do we still need this? |
Codecov Report
@@ Coverage Diff @@
## master #7417 +/- ##
==========================================
- Coverage 65.8% 65.65% -0.15%
==========================================
Files 461 461
Lines 22090 22090
Branches 2422 2422
==========================================
- Hits 14536 14504 -32
- Misses 7433 7465 +32
Partials 121 121
Continue to review full report at Codecov.
|
Actually just realized that a very similar PR was merged, no need for this anymore |
This fix is to make sure the scoped session created by the superset
init code (that creates a bunch of roles and permissions) will
be released and potentially committed when the superset/init.py
goes out of scope.
CATEGORY
Choose one
SUMMARY
Without running in a context, the code leaves the session open with a lock on ab_view_menu
metadata, which prevents migration cefabc8f7d38_increase_size_of_name_column_in_ab_view
from running an ALTER on that table.
Another contributor suggested explicitly closing the session or trying to use the same session inside the migration code. This requires more engineering and the sm.session.close() would have to be explicit. Any new interaction with the database would cause the problem to happen again.
See here: #1260 (comment)
I found using an app context to work better to encapsulate the superset init code, in case people add more logic there, the session close will happen automatically as the context goes out of scope.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TEST PLAN
Run migrations using mysql to version 3e1b21cd94a4
Run migrations to cefabc8f7d38
Without the fix, it should hang on the ALTER ab_view_menu, and with the fix it will complete.
ADDITIONAL INFORMATION
REVIEWERS