ashb commented on a change in pull request #19842:
URL: https://github.com/apache/airflow/pull/19842#discussion_r757580273
##########
File path: airflow/jobs/scheduler_job.py
##########
@@ -234,8 +234,25 @@ def _executable_task_instances_to_queued(self, max_tis:
int, session: Session =
:type max_tis: int
:return: list[airflow.models.TaskInstance]
"""
+ from airflow.utils.db import DBLocks
+
executable_tis: List[TI] = []
+ if session.get_bind().dialect.name == "postgresql":
+ # Optimization: to avoid littering the DB errors of "ERROR:
canceling statement due to lock
+ # timeout", try to take out a transactional advisory lock (unlocks
automatically on
+ # COMMIT/ROLLBACK)
+ lock_acquired = session.execute(
+ text("SELECT pg_try_advisory_xact_lock(:id)").bindparams(
+ id=DBLocks.SCHEDULER_CRITICAL_SECTION
Review comment:
Thanks -- it works anyway (as its an IntEnum) but better to be explicit
I agree.
--
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]