-
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
chore: Set isolation level to READ COMMITTED for testing et al. #28628
chore: Set isolation level to READ COMMITTED for testing et al. #28628
Conversation
4076016
to
05a93c6
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #28628 +/- ##
===========================================
+ Coverage 60.48% 83.72% +23.23%
===========================================
Files 1931 518 -1413
Lines 76236 37523 -38713
Branches 8568 0 -8568
===========================================
- Hits 46114 31416 -14698
+ Misses 28017 6107 -21910
+ Partials 2105 0 -2105
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
05a93c6
to
da94f58
Compare
da94f58
to
8639177
Compare
8639177
to
6557097
Compare
@@ -52,12 +54,15 @@ | |||
if "UPLOAD_FOLDER" in os.environ: # noqa: F405 | |||
UPLOAD_FOLDER = os.environ["UPLOAD_FOLDER"] # noqa: F405 | |||
|
|||
if "sqlite" in SQLALCHEMY_DATABASE_URI: | |||
if make_url(SQLALCHEMY_DATABASE_URI).get_backend_name() == "sqlite": |
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.
Safer than doing a string match.
@john-bodley looking at the changed files I was not able to see where you set the isolation level to READ COMMITTED in this PR. Did you forget to commit something? |
@michael-s-molina I updated the PR title and description. It's actually hard to set this globally given that not all of our backends support the |
# isolation level is READ COMMITTED. All backends should use READ COMMITTED (or similar) | ||
# to help ensure consistent behavior. | ||
SQLALCHEMY_ENGINE_OPTIONS = { | ||
"isolation_level": "SERIALIZABLE", # SQLite does not support READ COMMITTED. |
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.
@john-bodley Reading this it looks like everything will be SERIALIZABLE
right? we're overriding it in the tests but are we overriding it as READ COMMITTED
anywhere else for the other databases?
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.
@sadpandajoe followed the rabbit hole here, and I think you're right, this will bump all envs who don't set their SQLALCHEMY_ENGINE_OPTIONS to a higher isolation level.
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.
How about this draft? #30174
#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
SUMMARY
The default isolation level for PostgreSQL is
READ COMMITTED
whereas for MySQL it isREPEATABLE READ
. Ideally we would strive to have these the same (for consistency reasons) and the former is likely preferred given the async nature of Superset (especially SQL Lab) where the backend is polling to determine whether a query has been cancelled from another Flask-SQLAlchemy session.This PR:
config.py
to try to persuade institutions to set the isolation level. It's actually hard/difficult to impose this given that the default config is configured for SQLite which doesn't supportREAD COMMITTED
.READ COMMITTED
.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
CI.
ADDITIONAL INFORMATION