chore: Set isolation level to READ COMMITTED for testing et al. (#28628)

This commit is contained in:
John Bodley
2024-06-13 09:36:25 -07:00
committed by GitHub
parent 53798c7904
commit f185bbed3c
3 changed files with 19 additions and 2 deletions

View File

@@ -196,6 +196,13 @@ SQLALCHEMY_DATABASE_URI = (
# SQLALCHEMY_DATABASE_URI = 'mysql://myapp@localhost/myapp'
# SQLALCHEMY_DATABASE_URI = 'postgresql://root:password@localhost/myapp'
# The default MySQL isolation level is REPEATABLE READ whereas the default PostgreSQL
# 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.
}
# In order to hook up a custom password store for all SQLALCHEMY connections
# implement a function that takes a single argument of type 'sqla.engine.url',
# returns a password and set SQLALCHEMY_CUSTOM_PASSWORD_STORE.

View File

@@ -20,6 +20,8 @@ import math
from copy import copy
from datetime import timedelta
from sqlalchemy.engine import make_url
from superset.config import * # noqa: F403
from superset.config import DATA_DIR
from tests.integration_tests.superset_test_custom_template_processors import (
@@ -52,12 +54,15 @@ if "SUPERSET__SQLALCHEMY_EXAMPLES_URI" in os.environ: # noqa: F405
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":
logger.warning( # noqa: F405
"SQLite Database support for metadata databases will be "
"removed in a future version of Superset."
)
if make_url(SQLALCHEMY_DATABASE_URI).get_backend_name() in ("postgresql", "mysql"):
SQLALCHEMY_ENGINE_OPTIONS["isolation_level"] = "READ COMMITTED" # noqa: F405
# Speeding up the tests.integration_tests.
PRESTO_POLL_INTERVAL = 0.1
HIVE_POLL_INTERVAL = 0.1

View File

@@ -17,6 +17,8 @@
# type: ignore
from copy import copy
from sqlalchemy.engine import make_url
from superset.config import * # noqa: F403
from superset.config import DATA_DIR
@@ -33,12 +35,15 @@ DEBUG = True
if "SUPERSET__SQLALCHEMY_DATABASE_URI" in os.environ: # noqa: F405
SQLALCHEMY_DATABASE_URI = os.environ["SUPERSET__SQLALCHEMY_DATABASE_URI"] # noqa: F405
if "sqlite" in SQLALCHEMY_DATABASE_URI:
if make_url(SQLALCHEMY_DATABASE_URI).get_backend_name() == "sqlite":
logger.warning( # noqa: F405
"SQLite Database support for metadata databases will be removed \
in a future version of Superset."
)
if make_url(SQLALCHEMY_DATABASE_URI).get_backend_name() in ("postgresql", "mysql"):
SQLALCHEMY_ENGINE_OPTIONS["isolation_level"] = "READ COMMITTED" # noqa: F405
SQL_SELECT_AS_CTA = True
SQL_MAX_ROW = 666