This is an automated email from the ASF dual-hosted git repository.

jedcunningham pushed a commit to branch v2-2-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit b329f8d3d71ead96f8ef7d5f6eb51f0525993b9d
Author: jordanjeremy <72943478+jordanjer...@users.noreply.github.com>
AuthorDate: Thu Oct 14 02:55:12 2021 -0500

    Fix XCom.delete error in Airflow 2.2.0 (#18956)
    
    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”
    
    (cherry picked from commit 47c5973b3d1ad6d492fb1ceff19d5ec43b8e74af)
---
 airflow/models/xcom.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/airflow/models/xcom.py b/airflow/models/xcom.py
index 26dc3bc..99c2b9a 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")
 

Reply via email to