Fix: Restore task_instance_history sequence on downgrade#61976
Conversation
0e9bec6 to
13e2ef9
Compare
|
@ephraimbuddy could use a re-review |
ephraimbuddy
left a comment
There was a problem hiding this comment.
The sqlite branch might not also give a deterministic sequence but since it's sqlite, we can ignore it.
LGTM, just nit
12cc743 to
9a9b64d
Compare
Backport failed to create: v3-1-test. View the failure log Run detailsNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
You can attempt to backport this manually by running: cherry_picker 5d9b5df v3-1-testThis should apply the commit to the v3-1-test branch and leave the commit in conflict state marking After you have resolved the conflicts, you can continue the backport process by running: cherry_picker --continueIf you don't have cherry-picker installed, see the installation guide. |
* fix: restore task_instance_history_id_seq during downgrade (cherry picked from commit 5d9b5df)
* fix: restore task_instance_history_id_seq during downgrade (cherry picked from commit 5d9b5df)
* fix: restore task_instance_history_id_seq during downgrade
During a rollback from Airflow 3 to Airflow 2, the
task_instance_history_id_seqPostgreSQL sequence was not being recreated. This causedtask_instance_historyinserts to fail with NULL constraint violations since theidcolumn had no DEFAULT value for auto-increment.Root Cause
In the upgrade path (migration 0060), the
idcolumn is dropped:batch_op.drop_column("id")When PostgreSQL drops a column with an associated sequence, the sequence is also dropped (due to ownership).
Testing
breeze start-airflow --executor CeleryExecutor --backend postgresairflow db downgrade --to-revision e00344393f31 -y{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.