jordanjeremy commented on pull request #18956:
URL: https://github.com/apache/airflow/pull/18956#issuecomment-943355953


   @potiuk I do not believe that any migration changes are required.  In the 
Airflow 2.2.0 update changes were made to add a foreign key between the 
task_instance and dag_run tables.  As part of that the dag_run table columns 
for dag_id and execution_date had the not null constraint added 
(https://github.com/apache/airflow/commit/e6c56c4ae475605636f4a1b5ab3884383884a8cf).
   
   This change doesn't really change the relationship between the xcom and 
dag_run tables.  It is changing what sqlalchemy tries to do when an xcom is 
deleted.  From the [sqlalchemy 
documentation](https://docs.sqlalchemy.org/en/14/orm/relationship_api.html#sqlalchemy.orm.relationship.params.passive_deletes),
 the default behavior:
   `Normally, when a parent item is deleted, all child items are loaded so that 
they can either be marked as deleted, or have their foreign key to the parent 
set to NULL`
   
   So when deleting the xcom, sqlalchemy tried to set the dag_id and 
execution_date in the dag_run table to null, which is when the error happened 
due to the recently added not null constraint.
   
   The change in this request stops sqlalchemy from trying to also update the 
dag_run table when deleting an xcom record.
   `setting the flag to the string value ‘all’ will disable the “nulling out” 
of the child foreign keys`
    


-- 
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]


Reply via email to