Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions airflow/jobs/scheduler_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,21 @@ def _executable_task_instances_to_queued(self, max_tis: int, session: Session) -

query = query.limit(max_tis)

task_instances_to_examine: list[TI] = with_row_locks(
query,
of=TI,
session=session,
**skip_locked(session=session),
).all()
timer = Stats.timer("scheduler.critical_section_query_duration")
timer.start()

try:
task_instances_to_examine: list[TI] = with_row_locks(
query,
of=TI,
session=session,
**skip_locked(session=session),
).all()
timer.stop(send=True)
except OperationalError as e:
timer.stop(send=False)
raise e

# TODO[HA]: This was wrong before anyway, as it only looked at a sub-set of dags, not everything.
# Stats.gauge('scheduler.tasks.pending', len(task_instances_to_examine))

Expand Down
1 change: 1 addition & 0 deletions docs/apache-airflow/logging-monitoring/metrics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ Name Description
start date and the actual DagRun start date
``scheduler.critical_section_duration`` Milliseconds spent in the critical section of scheduler loop --
only a single scheduler can enter this loop at a time
``scheduler.critical_section_query_duration`` Milliseconds spent running the critical section task instance query
``scheduler.scheduler_loop_duration`` Milliseconds spent running one scheduler loop
``dagrun.<dag_id>.first_task_scheduling_delay`` Seconds elapsed between first task start_date and dagrun expected start
``collect_db_dags`` Milliseconds taken for fetching all Serialized Dags from DB
Expand Down