|
75 | 75 | from airflow.utils.retries import MAX_DB_RETRIES, retry_db_transaction, run_with_db_retries |
76 | 76 | from airflow.utils.session import NEW_SESSION, create_session, provide_session |
77 | 77 | from airflow.utils.span_status import SpanStatus |
78 | | -from airflow.utils.sqlalchemy import is_lock_not_available_error, prohibit_commit, with_row_locks |
| 78 | +from airflow.utils.sqlalchemy import ( |
| 79 | + is_lock_not_available_error, |
| 80 | + prohibit_commit, |
| 81 | + make_dialect_kwarg, |
| 82 | + with_row_locks, |
| 83 | +) |
79 | 84 | from airflow.utils.state import DagRunState, JobState, State, TaskInstanceState |
80 | 85 | from airflow.utils.thread_safe_dict import ThreadSafeDict |
81 | 86 | from airflow.utils.types import DagRunTriggeredByType, DagRunType |
|
102 | 107 | TASK_STUCK_IN_QUEUED_RESCHEDULE_EVENT = "stuck in queued reschedule" |
103 | 108 | """:meta private:""" |
104 | 109 |
|
| 110 | +dialect_kwarg = make_dialect_kwarg("mysql") |
| 111 | + |
105 | 112 |
|
106 | 113 | class SchedulerDagBag: |
107 | 114 | """ |
@@ -400,7 +407,7 @@ def _executable_task_instances_to_queued(self, max_tis: int, session: Session) - |
400 | 407 |
|
401 | 408 | query = ( |
402 | 409 | select(TI) |
403 | | - .with_hint(TI, "USE INDEX (ti_state)", dialect_name="mysql") |
| 410 | + .with_hint(TI, "USE INDEX (ti_state)", **dialect_kwarg) |
404 | 411 | .join(TI.dag_run) |
405 | 412 | .where(DR.state == DagRunState.RUNNING) |
406 | 413 | .join(TI.dag_model) |
@@ -2237,7 +2244,7 @@ def _find_task_instances_without_heartbeats(self, *, session: Session) -> list[T |
2237 | 2244 | .options(selectinload(TI.dag_model)) |
2238 | 2245 | .options(selectinload(TI.dag_run)) |
2239 | 2246 | .options(selectinload(TI.dag_version)) |
2240 | | - .with_hint(TI, "USE INDEX (ti_state)", dialect_name="mysql") |
| 2247 | + .with_hint(TI, "USE INDEX (ti_state)", **dialect_kwarg) |
2241 | 2248 | .join(DM, TI.dag_id == DM.dag_id) |
2242 | 2249 | .where( |
2243 | 2250 | TI.state.in_((TaskInstanceState.RUNNING, TaskInstanceState.RESTARTING)), |
|
0 commit comments