8silvergun opened a new pull request, #66785:
URL: https://github.com/apache/airflow/pull/66785

     closes: #66763
   
     ## Summary
   
     `SchedulerJobRunner._executable_task_instances_to_queued` applied `USE 
INDEX (ti_state)` twice on MySQL: once on the
     inner ranked query that filters by scheduled task instances, and once on 
the outer rejoin that looks up
     `task_instance` by `(dag_id, task_id, run_id, map_index)`.
   
     The outer query is an exact identity lookup, so forcing `ti_state` can 
prevent MySQL from using
     `task_instance_composite_key`. This PR removes only the outer hint and 
keeps the inner hint that was added for the
     original MySQL scheduler optimization.
   
     ## Regression Coverage
   
     Added a regression test that compiles the scheduler selection query with 
the MySQL dialect and verifies `USE INDEX
     (ti_state)` appears only once.
   
     ## Tests
   
     - `uv run --python 3.12 --group dev pytest airflow-core/tests/unit/jobs/ 
-xvs`
     - `prek run ruff --from-ref main`
     - `prek run ruff-format --from-ref main`
   
     ## Context
   
     - #25627 added the original MySQL `ti_state` hint for the scheduler state 
lookup.
     - #54103 reshaped this scheduler query into the ranked subquery plus outer 
rejoin form; that is where the hint was
     also applied to the outer rejoin.
     - #57210 touched the same scheduling path, but covers deferred-task 
priority rather than this MySQL hint placement.
   
     ---
   
     ##### Was generative AI tooling used to co-author this PR?
   
     - [X] Yes — OpenAI Codex
   
     Generated-by: OpenAI Codex following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-
     docs/05_pull_requests.rst#gen-ai-assisted-contributions)


-- 
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]

Reply via email to