Greetlist opened a new issue #21817: URL: https://github.com/apache/airflow/issues/21817
### Apache Airflow version 2.2.1 ### What happened My Scheduler or Trigger Process throw DeadLock Exception randomly. Scheduler log:  Trigger log:  Scheduler exception is thrown out by ``` SchedulerJob.check_trigger_timeouts``` function Trigger exception is thrown out by ``` Trigger.submit_event ``` function ### What you expected to happen Scheduler or Trigger Process never throw DeadLock Exception. ### How to reproduce _No response_ ### Operating System Ubuntu 16.04 ### Versions of Apache Airflow Providers _No response_ ### Deployment Other ### Deployment details 1. Three Scheduler 2. One WebServer 3. One Trigger ### Anything else I think these codes may have conflict:   Due to ``` task_instance.trigger_timeout ``` column is not index, Scheduler query may **lock all records whose state == "deferred"**. If Trigger.submib_event try to update these records which locked by Scheduler, should get deadlock. Now, I fix this bug by adding ``` with_row_locked ``` with these two query:   Hope for reply. ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md) -- 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]
