ColtenOuO opened a new pull request, #67198: URL: https://github.com/apache/airflow/pull/67198
When `dagrun_timeout` fires, the scheduler loaded every unfinished TaskInstance, set its state in Python, and called `session.merge()` per row. The TIs are already attached to the session, so the merge is redundant and the ORM unit-of-work flush emits one UPDATE per row — N statements for N tasks. This PR replaces the loop with a single `update(TI).where(TI.id.in_(...))` and `synchronize_session="fetch"`, matching the bulk pattern already used at [scheduler_job_runner.py:798-803](https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/jobs/scheduler_job_runner.py#L798-L803) and aligning with the AGENTS.md rule to batch scheduler DELETE/UPDATE (#66908). Behaviour is unchanged. -- 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]
