From c7e188fdac9739c564bf87f1e39b146f1c5f92ff Mon Sep 17 00:00:00 2001 From: Jarek Potiuk Date: Tue, 4 Jul 2023 12:27:18 +0200 Subject: [PATCH] Retry transactions on occasional deadlocks for rendered fields This is a follow-up on #18616 where we introduced retries on the occassional deadlocks when rendered task fields have been deleted by parallel threads (this is not a real deadlock, it's because MySQL locks too many things when queries are executed and will deadlock when one of those queries wait too much). Adding retry - while not perfect - should allow to handle the problem and significantly decrease the likelihood of such deadlocks. We can probably think about different approach for rendered fields, but for now retrying is - I think - acceptable short-term fix. Fixes: #32294 Fixes: #29687 --- airflow/models/renderedtifields.py | 1 + 1 file changed, 1 insertion(+) diff --git a/airflow/models/renderedtifields.py b/airflow/models/renderedtifields.py index 8cea81715f37c..9586834470043 100644 --- a/airflow/models/renderedtifields.py +++ b/airflow/models/renderedtifields.py @@ -175,6 +175,7 @@ def get_k8s_pod_yaml(cls, ti: TaskInstance, session: Session = NEW_SESSION) -> d return result.k8s_pod_yaml if result else None @provide_session + @retry_db_transaction def write(self, session: Session = None): """Write instance to database.