Skip to content

Commit

Permalink
Improve trigger assign_unassigned by merging alive_triggerer_ids and …
Browse files Browse the repository at this point in the history
…get_sorted_triggers queries
  • Loading branch information
hussein-awala committed Apr 1, 2024
1 parent 9c61147 commit cc2685a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions airflow/models/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,11 @@ def assign_unassigned(
if capacity <= 0:
return

alive_triggerer_ids = session.scalars(
select(Job.id).where(
Job.end_date.is_(None),
Job.latest_heartbeat > timezone.utcnow() - datetime.timedelta(seconds=health_check_threshold),
Job.job_type == "TriggererJob",
)
).all()
alive_triggerer_ids = select(Job.id).where(
Job.end_date.is_(None),
Job.latest_heartbeat > timezone.utcnow() - datetime.timedelta(seconds=health_check_threshold),
Job.job_type == "TriggererJob",
)

# Find triggers who do NOT have an alive triggerer_id, and then assign
# up to `capacity` of those to us.
Expand Down

0 comments on commit cc2685a

Please sign in to comment.