-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
Add indexes for CASCADE deletes for task_instance #24488
Add indexes for CASCADE deletes for task_instance #24488
Conversation
airflow/migrations/versions/0111_2_4_0_add_indexes_for_cascade_deletes.py
Outdated
Show resolved
Hide resolved
airflow/migrations/versions/0111_2_4_0_add_indexes_for_cascade_deletes.py
Outdated
Show resolved
Hide resolved
airflow/migrations/versions/0111_2_4_0_add_indexes_for_cascade_deletes.py
Outdated
Show resolved
Hide resolved
airflow/migrations/versions/0111_2_4_0_add_indexes_for_cascade_deletes.py
Outdated
Show resolved
Hide resolved
airflow/migrations/versions/0111_2_4_0_add_indexes_for_cascade_deletes.py
Outdated
Show resolved
Hide resolved
airflow/migrations/versions/0111_2_4_0_add_indexes_for_cascade_deletes.py
Outdated
Show resolved
Hide resolved
airflow/migrations/versions/0111_2_4_0_add_indexes_for_cascade_deletes.py
Outdated
Show resolved
Hide resolved
airflow/migrations/versions/0111_2_4_0_add_indexes_for_cascade_deletes.py
Outdated
Show resolved
Hide resolved
0701258
to
55a576d
Compare
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. |
When we add foreign keys with ON DELETE CASCADE, and we delete rows in the foreign table, the database needs to join back to the referencing table. If there's no suitable index, then it can be slow to perform the deletes.
a464bb5
to
a350845
Compare
When we add foreign keys with ON DELETE CASCADE, and we delete rows in the foreign table, the database needs to join back to the referencing table. If there's no suitable index, then it can be slow to perform the deletes. (cherry picked from commit 677c422)
Upgrading airflow 2.3.2 to 2.3.3, db upgrade failed: Running upgrade 3c94c427fdf6 -> f5fcbda3e651, Add indexes for CASCADE deletes on task_instance (MySQL 8.0) I checked that my |
@calfzhou - you might have your mysql configured with "NO ZERO DATE" and "STRICT MODE". Can you please confirm that? If so, you might want to disable it - https://stackoverflow.com/questions/9192027/invalid-default-value-for-create-date-timestamp-field. |
Thanks @potiuk , that works! I removed |
Cool! One question @calfzhou - maybe you would like to add a note about it as PR to https://airflow.apache.org/docs/apache-airflow/stable/howto/set-up-database.html?highlight=database+setup#setting-up-a-mysql-database ? We already have a few watch-outs there and adding this one might be useful for others. It's super easy - just click "Suggest a change on this page" and you will get a PR where you will be able to directly edit the page sources and you could just use similar approach as other warnings there ? |
PR posted #24983 |
When we add foreign keys with ON DELETE CASCADE, and we delete rows in the foreign table, the database needs to join back to the referencing table. If there's no suitable index, then it can be slow to perform the deletes.
cc @wolfier
closes #24484