pharctor opened a new pull request, #77305: URL: https://github.com/apache/airflow/pull/77305
`_update_dag_run_state_for_paused_dags` catches its own exceptions so that a failed sweep does not stop the scheduler, but after a failed flush it leaves the session in a failed state. `@provide_session` then commits that session when the method returns, which raises `PendingRollbackError` outside the handler. The timer is registered without `non_fatal=True`, so that error ends the scheduler loop. This rolls the session back in the handler, so a failed sweep costs one cycle and the next sweep, 60 s later, reads fresh rows. `retry_db_transaction` rolls back for the same reason before it re-raises. A clear that commits between the sweep's read and its flush triggers it: `prepare_db_for_next_try` gives each cleared task instance a new primary key, so the sweep's UPDATE on the old one matches no row (`StaleDataError`). The new test reproduces that deterministically and calls the sweep without a session, as the timer does. It fails on `main` with `PendingRollbackError` and passes with this change. closes: #77300 --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes (please specify the tool below) Generated-by: Claude Code (Opus 5.5) 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]
