-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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: set default mysql isolation level to 'READ COMMITTED' #30174
Conversation
#28628 had the virtuous intent to align mysql and postgres to a consistent isolation_level (READ COMMITTED), which seems fitted for Superset. Though instead of doing this, and because sqlite doesn't support that specific one, it set the default to SERIALIZABLE which seems to exist by many engines. Here I'm realizing we need dynamic defaults for isolation_level based on which engine is in used, which can't be done in config.py as we don't know yet what engine will be set by the admin at that time. So I thought the superset/initialization package might be the right place for this. Open to other solutions, but I think this one works. * using DB_CONNECTION_MUTATOR, but that one applies only to analytics workloads, not the metadata db
superset/initialization/__init__.py
Outdated
if not isolation_level and self.config["SQLALCHEMY_DATABASE_URI"].startswith( | ||
"mysql" | ||
): |
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.
I kinda liked John's cleaner way of extracting the backend name:
backend = make_url(SQLALCHEMY_DATABASE_URI).get_backend_name()
Also, weren't we supposed to do READ COMMITTED
by default for Postgres, 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.
ok, I addressed comments, lover how pre-commit caught something around make_url
not being safe to use so I found I can use make_url_safe
Co-authored-by: Ville Brofeldt <[email protected]>
Wondering since the original pr is a breaking change if we should pull it out of 4.1 and wait until 5.0 to incorporate it. |
@villebro do you think that's mergeable? |
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.
LGTM!
@@ -1 +1,2 @@ | |||
docker/**/*.sh text eol=lf | |||
*.svg binary |
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.
Unrelated bycatch, I assume..
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.
Yup, Ill search for say a model name and the erd.svg muddies my git grep
Co-authored-by: Ville Brofeldt <[email protected]> (cherry picked from commit 6baeb65)
#28628 had the virtuous intent to align mysql and postgres to a consistent isolation_level (READ COMMITTED), which seems fitted for Superset. Though instead of doing this, and because sqlite doesn't support that specific one, it set the default to SERIALIZABLE which seems to exist by many engines.
Now SERIALIZABLE can create issues like this one: #30064 and upping the isolation level can have serious load implications for large deployments (or databases that are fitted "just-right" for their loads, like someone may use a tiny RDS for Superset)
Here I'm realizing we need dynamic defaults for isolation_level based on which engine is in used, which can't be done in config.py as we don't know yet what engine will be set by the admin at that time. So I thought the superset/initialization package might be the right place for this.
Open to other solutions, but I think this one works.
alternative considered