villebro commented on code in PR #30174:
URL: https://github.com/apache/superset/pull/30174#discussion_r1747588886
##########
superset/initialization/__init__.py:
##########
@@ -482,12 +483,39 @@ def init_app(self) -> None:
self.configure_wtf()
self.configure_middlewares()
self.configure_cache()
+ self.set_db_default_isolation()
with self.superset_app.app_context():
self.init_app_in_ctx()
self.post_init()
+ def set_db_default_isolation(self) -> None:
+ # This block sets the default isolation level for mysql to READ
COMMITTED if not
+ # specified in the config. You can set your isolation in the config by
using
+ # SQLALCHEMY_ENGINE_OPTIONS
+ eng_options = self.config["SQLALCHEMY_ENGINE_OPTIONS"] or {}
+ isolation_level = eng_options.get("isolation_level")
+ set_isolation_level_to = None
+
+ if not isolation_level:
+ backend = make_url_safe(
+ self.config["SQLALCHEMY_DATABASE_URI"]
+ ).get_backend_name()
+ if backend == "mysql":
+ set_isolation_level_to = "READ COMMITTED"
+ elif backend == "postgresql":
+ set_isolation_level_to = "READ COMMITTED"
Review Comment:
As these are identical, can't we just
```suggestion
if backend in ("mysql", "postgresql"):
set_isolation_level_to = "READ COMMITTED"
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]