Retry deadlocked transactions on deleting old rendered task fields (#18616)
Retry deadlocked transactions on deleting old rendered task fields (#18616)



The query that deletes rendered old rendered task fields for MySQL
can occasionally deadlock because it is unncesssary complex with
a subquery (due to features missing in MySQL). This change
adds DB retries to get rid of the deadlock (as is the
recommended practice for MySQL).

Fixes: #18512

* Update airflow/models/renderedtifields.py

Co-authored-by: Kaxil Naik <762f1fed708bdb04af3f52cafbce77c382effa7a@gmail.com>

* Apply suggestions from code review

Co-authored-by: Ash Berlin-Taylor <c98219fa5869fa00c16554b67c9fb7547acd11f2@firemirror.com>

Co-authored-by: Kaxil Naik <762f1fed708bdb04af3f52cafbce77c382effa7a@gmail.com>
Co-authored-by: Ash Berlin-Taylor <c98219fa5869fa00c16554b67c9fb7547acd11f2@firemirror.com>
cfei18/incubator-airflow,mistercrunch/airflow,cfei18/incubator-airflow,cfei18/incubator-airflow,lyft/incubator-airflow,nathanielvarona/airflow,apache/airflow,mistercrunch/airflow,mistercrunch/airflow,cfei18/incubator-airflow,Acehaidrey/incubator-airflow,bolkedebruin/airflow,danielvdende/incubator-airflow,apache/airflow,lyft/incubator-airflow,bolkedebruin/airflow,bolkedebruin/airflow,apache/incubator-airflow,nathanielvarona/airflow,apache/airflow,bolkedebruin/airflow,Acehaidrey/incubator-airflow,nathanielvarona/airflow,apache/airflow,bolkedebruin/airflow,danielvdende/incubator-airflow,Acehaidrey/incubator-airflow,apache/incubator-airflow,cfei18/incubator-airflow,apache/incubator-airflow,danielvdende/incubator-airflow,danielvdende/incubator-airflow,Acehaidrey/incubator-airflow,Acehaidrey/incubator-airflow,apache/airflow,mistercrunch/airflow,lyft/incubator-airflow,danielvdende/incubator-airflow,Acehaidrey/incubator-airflow,cfei18/incubator-airflow,apache/airflow,nathanielvarona/airflow,apache/incubator-airflow,lyft/incubator-airflow,nathanielvarona/airflow,nathanielvarona/airflow,danielvdende/incubator-airflow