Make updating perms on init optional #625
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Whenever we re-deploy Superset at Airbnb, we restart 5 web servers which
all have a set of many Gunicorn workers.
Each one of these workers is a process and inits the FAB app, resulting
in a fair amount of database contention around perms tables, and sometimes ultimately
leading to bad database state as I suspect that the perms merge
operations aren't well transaction-insulated. We've added unique
constraints on the DB preventing that, but that's not a great solution.
This PR adds a flag to AppBuilder allowing to turn off perm updates on
init.
The default behavior stays unchanged though.
Note that I decided to add the condition inside
_add_menu_permissions
and_add_permissions
as opposed to adding them in the calling methods since they_add_permissions
is called multiple times and could be called in more places in the future. Adding the flag where perms are applied seemed less brittle. Happy to change it though if needed.