This is an automated email from the ASF dual-hosted git repository.
uranusjr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 7dc2b52436 Use SKIP LOCKED instead of NOWAIT in mini scheduler (#39745)
7dc2b52436 is described below
commit 7dc2b5243621f7a15ed1b44e1bf6eb81670f68d2
Author: Uladzimir Yushkevich <[email protected]>
AuthorDate: Tue May 28 03:03:07 2024 +0200
Use SKIP LOCKED instead of NOWAIT in mini scheduler (#39745)
---
airflow/models/taskinstance.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/airflow/models/taskinstance.py b/airflow/models/taskinstance.py
index 1b2485f702..c5eac4c8ab 100644
--- a/airflow/models/taskinstance.py
+++ b/airflow/models/taskinstance.py
@@ -3657,8 +3657,13 @@ class TaskInstance(Base, LoggingMixin):
run_id=ti.run_id,
),
session=session,
- nowait=True,
- ).one()
+ skip_locked=True,
+ ).one_or_none()
+
+ if not dag_run:
+ cls.logger().debug("Skip locked rows, rollback")
+ session.rollback()
+ return
task = ti.task
if TYPE_CHECKING: