-
Notifications
You must be signed in to change notification settings - Fork 14.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix XCom.delete error in Airflow 2.2.0 #18956
Fix XCom.delete error in Airflow 2.2.0 #18956
Conversation
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”
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
|
The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease. |
Awesome work, congrats on your first merged pull request! |
One doubt that came to me afer merging. Should we have a migration updated after that change @uranusjr @jordanjeremy ? |
@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 (e6c56c4). 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, the default behavior: 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. |
Correct, the relationship behaviour is handled entirely in Python and stores nothing in the database. |
Cool! Great to confirm that - I thought so, but I was not entirely sure :) |
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 47c5973)
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 47c5973)
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 47c5973)
In Airflow 2.2.0
XCom.delete
causes error, by trying to update dag_run table dag_id and execution_date columns to NULLs.Setting passive_deletes to the string value 'all' will disable the "nulling out" behavior.