rjgoyln opened a new pull request, #72596: URL: https://github.com/apache/airflow/pull/72596
## Summary `check_awaiting_input_timeouts` and `adopt_or_reset_orphaned_tasks` both run inside `run_with_db_retries`, so a deadlock should cost a scheduler tick rather than the scheduler. Neither loop survives one. A flush that raises leaves the SQLAlchemy transaction deactivated, so the retry's first statement raises `PendingRollbackError`. The retry predicate matches only `(DBAPIError, StaleDataError)`, so that escapes the loop — and the awaiting-input sweep sits on a timer registered without `non_fatal=True`, taking the scheduler loop with it. `retry_db_transaction` rolls back for exactly this reason; neither hand-rolled loop picked it up. The awaiting-input sweep never rolls back, and the orphaned-task sweep rolls back only for `OperationalError` though its loop also retries `StaleDataError`. ## Change - Roll back before re-raising in `check_awaiting_input_timeouts`, as `retry_db_transaction` does. - Widen the orphaned-task sweep's guard to `(DBAPIError, StaleDataError)`. The sweep body is unchanged apart from the indent under the new `try:`. `check_trigger_timeouts` is the third loop of this shape; #72595 covers it. ## Tests Both tests drive a session that deactivates on a failed flush the way SQLAlchemy does; all four cases fail on `main` with `PendingRollbackError`. --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes — Claude Code (Opus 5) Generated-by: Claude Code (Opus 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]
