dosubot[bot] commented on issue #30064: URL: https://github.com/apache/superset/issues/30064#issuecomment-2320762321
<!-- Greeting --> @mapledan Hello! I'm here to assist you with any bugs or questions you have. If you need any help, feel free to ask. <!-- Answer --> The `psycopg2.errors.SerializationFailure` error you're encountering after upgrading from version 4.0.2 to 4.1.0rc2 is likely due to changes in how SQL statements are executed and committed. Specifically, the `execute_sql_statements` function now includes a commit operation for certain types of queries: ```python # Commit the connection so CTA queries will create the table and any DML. should_commit = ( not db_engine_spec.is_select_query(parsed_query) # check if query is DML or apply_ctas ) if should_commit: conn.commit() ``` This commit operation can lead to serialization failures in PostgreSQL, especially in high-concurrency environments or when using certain isolation levels. The `SerializationFailure` error is typically a result of concurrent transactions interfering with each other, which is more likely to occur with the added commit operation <sup>[[1]](https://github.com/apache/superset/blob/master/superset/sql_lab.py)</sup>. To mitigate this issue, you can set the `isolation_level` to `READ COMMITTED` in the `SQLALCHEMY_ENGINE_OPTIONS` for PostgreSQL databases. This setting can help reduce the likelihood of `SerializationFailure` errors by using a less strict isolation level: ```python if make_url(SQLALCHEMY_DATABASE_URI).get_backend_name() in ("postgresql", "mysql"): SQLALCHEMY_ENGINE_OPTIONS["isolation_level"] = "READ COMMITTED" # noqa: F405 ``` This configuration can be added to your Superset configuration file <sup>[[2]](https://github.com/apache/superset/blob/master/tests/integration_tests/superset_test_config.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* -- 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: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org