Skip to content

Commit

Permalink
Fixing up tests, removing indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
SamWheating committed May 8, 2021
1 parent 79adaa5 commit 1aba800
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
14 changes: 7 additions & 7 deletions airflow/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,13 @@ def prepare_engine_args(disable_connection_pool=False):
engine_args['pool_pre_ping'] = pool_pre_ping
engine_args['max_overflow'] = max_overflow

# The default isolation level for MySQL (REPEATABLE READ) can introduce inconsistencies when
# running multiple schedulers, as repeated queries on the same session may read from stale snapshots.
# 'READ COMMITTED' is the default value for PostgreSQL.
# More information here:
# https://dev.mysql.com/doc/refman/8.0/en/innodb-transaction-isolation-levels.html"
if SQL_ALCHEMY_CONN.startswith('mysql'):
engine_args['isolation_level'] = 'READ COMMITTED'
# The default isolation level for MySQL (REPEATABLE READ) can introduce inconsistencies when
# running multiple schedulers, as repeated queries on the same session may read from stale snapshots.
# 'READ COMMITTED' is the default value for PostgreSQL.
# More information here:
# https://dev.mysql.com/doc/refman/8.0/en/innodb-transaction-isolation-levels.html"
if SQL_ALCHEMY_CONN.startswith('mysql'):
engine_args['isolation_level'] = 'READ COMMITTED'

return engine_args

Expand Down
2 changes: 2 additions & 0 deletions tests/core/test_sqlalchemy_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def test_configure_orm_with_default_values(
pool_pre_ping=True,
pool_recycle=1800,
pool_size=5,
isolation_level='READ COMMITTED',
)

@patch('airflow.settings.setup_event_handlers')
Expand All @@ -80,6 +81,7 @@ def test_sql_alchemy_connect_args(
connect_args=SQL_ALCHEMY_CONNECT_ARGS,
poolclass=NullPool,
encoding='utf-8',
isolation_level='READ COMMITTED',
)

@patch('airflow.settings.setup_event_handlers')
Expand Down
2 changes: 2 additions & 0 deletions tests/www/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ def debug_view():
def test_should_set_sqlalchemy_engine_options(self):
app = application.cached_app(testing=True)
engine_params = {'pool_size': 3, 'pool_recycle': 120, 'pool_pre_ping': True, 'max_overflow': 5}
if app.config['SQLALCHEMY_DATABASE_URI'].startswith('mysql'):
engine_params['isolation_level'] = 'READ COMMITTED'
assert app.config['SQLALCHEMY_ENGINE_OPTIONS'] == engine_params

@conf_vars(
Expand Down

0 comments on commit 1aba800

Please sign in to comment.