anitakar commented on a change in pull request #16311:
URL: https://github.com/apache/airflow/pull/16311#discussion_r649373985
##########
File path: airflow/utils/db.py
##########
@@ -561,10 +571,21 @@ def create_default_connections(session=None):
)
-def initdb():
+@provide_session
+def initdb(session=None):
"""Initialize Airflow database."""
+ if session.connection().dialect.name == 'postgresql':
+ log.info('Acquiring lock on database')
+ session.connection().execute('select PG_ADVISORY_LOCK(1);')
+
upgradedb()
+ if session.connection().dialect.name == 'mysql' and
session.connection().dialect.server_version_info >= (
+ 5,
+ 6,
+ ):
+ session.connection().execute("select GET_LOCK('db_init',1800);")
Review comment:
Done
##########
File path: airflow/migrations/env.py
##########
@@ -101,9 +101,6 @@ def run_migrations_online():
with context.begin_transaction():
if connection.dialect.name == 'mysql' and
connection.dialect.server_version_info >= (5, 6):
connection.execute("select GET_LOCK('alembic',1800);")
- if connection.dialect.name == 'postgresql':
- context.get_context()._ensure_version_table() # pylint:
disable=protected-access
- connection.execute("LOCK TABLE alembic_version IN ACCESS
EXCLUSIVE MODE")
Review comment:
Done
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]