potiuk commented on a change in pull request #16311:
URL: https://github.com/apache/airflow/pull/16311#discussion_r662266524



##########
File path: airflow/utils/session.py
##########
@@ -70,3 +70,29 @@ def wrapper(*args, **kwargs) -> RT:
                 return func(*args, session=session, **kwargs)
 
     return wrapper
+
+
+@provide_session
[email protected]
+def create_global_lock(session=None, pg_lock_id=1, mysql_lock_name='init', 
mysql_lock_timeout=1800):
+    """Contextmanager that will create and teardown a global db lock."""
+    dialect = session.connection().dialect
+    if dialect.name == 'postgresql':
+        session.connection().execute(f'select PG_ADVISORY_LOCK({pg_lock_id});')
+
+    if dialect.name == 'mysql' and dialect.server_version_info >= (
+        5,
+        6,
+    ):
+        session.connection().execute(f"select 
GET_LOCK('{mysql_lock_name}',{mysql_lock_timeout});")

Review comment:
       With Breeze it's already there `--backend mssql` will bring the mssql 
database docker container up and configure Airflow to use use it .




-- 
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]


Reply via email to