From b11ccd438d56aa9bd9cd3a9df071f25ceb77bf74 Mon Sep 17 00:00:00 2001 From: jordanjeremy <72943478+jordanjeremy@users.noreply.github.com> Date: Wed, 13 Oct 2021 12:51:08 -0500 Subject: [PATCH] Fix XCom.delete error in Airflow 2.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Airflow 2.2.0 XCom.delete causes error, by trying to update dag_run table dag_id and execution_date columns to NULLs. sqlalchemy.exc.IntegrityError: (psycopg2.errors.NotNullViolation) null value in column "dag_id" violates not-null constraint [SQL: UPDATE dag_run SET dag_id=%(dag_id)s, execution_date=%(execution_date)s WHERE dag_run.id = %(dag_run_id)s] [parameters: {'dag_id': None, 'execution_date': None, 'dag_run_id': 2409}] Setting passive_deletes to the string value ‘all’ will disable the “nulling out” --- airflow/models/xcom.py | 1 + 1 file changed, 1 insertion(+) diff --git a/airflow/models/xcom.py b/airflow/models/xcom.py index 26dc3bcb734c8..99c2b9aca5b2b 100644 --- a/airflow/models/xcom.py +++ b/airflow/models/xcom.py @@ -64,6 +64,7 @@ class BaseXCom(Base, LoggingMixin): BaseXCom.execution_date == foreign(DagRun.execution_date) )""", uselist=False, + passive_deletes="all", ) run_id = association_proxy("dag_run", "run_id")