This is an automated email from the ASF dual-hosted git repository.

ephraimanierobi pushed a commit to branch v2-3-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit cf448ea1746a05ddd2cbb6005f7c238e69083d0f
Author: Michael Petro <[email protected]>
AuthorDate: Fri Aug 12 07:28:55 2022 -0400

    Adding mysql index hint to use index on task_instance.state in critical 
section query (#25673)
    
    (cherry picked from commit 134b5551db67f17b4268dce552e87a154aa1e794)
---
 airflow/jobs/scheduler_job.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/airflow/jobs/scheduler_job.py b/airflow/jobs/scheduler_job.py
index 539e6f1eff..888922840b 100644
--- a/airflow/jobs/scheduler_job.py
+++ b/airflow/jobs/scheduler_job.py
@@ -314,6 +314,7 @@ class SchedulerJob(BaseJob):
             # and the dag is not paused
             query = (
                 session.query(TI)
+                .with_hint(TI, 'USE INDEX (ti_state)', dialect_name='mysql')
                 .join(TI.dag_run)
                 .filter(DR.run_type != DagRunType.BACKFILL_JOB, DR.state == 
DagRunState.RUNNING)
                 .join(TI.dag_model)

Reply via email to