potiuk commented on a change in pull request #16311:
URL: https://github.com/apache/airflow/pull/16311#discussion_r661017746
##########
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:
One more comment. We have - as of recently - `mssql` support. In order
to make it complete, we should support it too.
--
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]