Repository navigation
Allow downgrading past the TI ownership migration when data is present. - #74407
Merged
Merged
Conversation
ashb
commented
Oct 7, 2026
kaxil
reviewed
Oct 7, 2026
ashb
force-pushed
the
worktree-migration0142-downgrade
branch
from
October 8, 2026 14:42
e71c0b3 to
ad93457
Compare
kaxil
reviewed
Oct 14, 2026
kaxil
approved these changes
Oct 14, 2026
The 0142 downgrade refused whenever xcom_v2 or rtif_v2 held rows or any task had retried since the upgrade, so a rollback after any real use of 3.4 was impossible. It now folds that data back into the legacy tables as if 3.3 had written it. That is only lossless for the latest attempt: the legacy tables are keyed by task coordinates and can hold values for one attempt, so earlier attempts' XCom and rendered fields are dropped while the attempts themselves move back to task_instance_history. The release note records that cost and the runtime, which grows with the size of xcom and rendered_task_instance_fields. Data 3.3 cannot represent (several attempts sharing coordinates, archived attempts with no current attempt, owners that moved while legacy rows exist) is refused by read-only checks before the first write, because MySQL cannot roll back DDL. Past that point a failure on MySQL leaves the schema partly downgraded and needs a restore from backup. The downgrade leaves try_number alone. Migration 0138's downgrade already subtracts one from pending retries and runs after this one on any downgrade to 3.3, so rewinding here as well made a retried task reuse an archived try number. Only a test that downgrades through 0138 can see it. Expansion now deletes the archived attempts of an unmapped task instance. Once it is promoted or removed they have no current attempt, and a cleared mapped task would make every later downgrade refuse. The delete is scoped to the placeholder's own region so expanding one loop pass cannot remove a sibling pass's archived attempts. It discards real earlier runs of a task that later became mapped.
ashb
force-pushed
the
worktree-migration0142-downgrade
branch
from
October 15, 2026 09:48
ad93457 to
a065aec
Compare
Contributor
Backport failed to create: v3-4-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 a87c6dd v3-4-testThis should apply the commit to the v3-4-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. |
ashb
added a commit
that referenced
this pull request
Oct 15, 2026
…ta is present (#74407) The 0142 downgrade refused whenever xcom_v2 or rtif_v2 held rows or any task had retried since the upgrade, so a rollback after any real use of 3.4 was impossible. It now folds that data back into the legacy tables as if 3.3 had written it. That is only lossless for the latest attempt: the legacy tables are keyed by task coordinates and can hold values for one attempt, so earlier attempts' XCom and rendered fields are dropped while the attempts themselves move back to task_instance_history. The release note records that cost and the runtime, which grows with the size of xcom and rendered_task_instance_fields. Data 3.3 cannot represent (several attempts sharing coordinates, archived attempts with no current attempt, owners that moved while legacy rows exist) is refused by read-only checks before the first write, because MySQL cannot roll back DDL. Past that point a failure on MySQL leaves the schema partly downgraded and needs a restore from backup. The downgrade leaves try_number alone. Migration 0138's downgrade already subtracts one from pending retries and runs after this one on any downgrade to 3.3, so rewinding here as well made a retried task reuse an archived try number. Only a test that downgrades through 0138 can see it. Expansion now deletes the archived attempts of an unmapped task instance. Once it is promoted or removed they have no current attempt, and a cleared mapped task would make every later downgrade refuse. The delete is scoped to the placeholder's own region so expanding one loop pass cannot remove a sibling pass's archived attempts. It discards real earlier runs of a task that later became mapped. (cherry picked from commit a87c6dd)
Member
Author
|
Pushed to 2af7b35 on v3-4-test. |
vatsrahul1001
pushed a commit
that referenced
this pull request
Oct 20, 2026
) test_promotion_leaves_earlier_placeholder_task_instances_at_their_coordinates asserted that the archived -1 attempt of a mapped task survives expansion. Since #74407 expansion deletes those attempts, but the delete runs with synchronize_session=False, so session.get() kept returning the stale identity-map object and the test passed while asserting the opposite of what the database holds. Expire the session and query the database, asserting the archived placeholder attempt is gone, and rename the test to match.
vatsrahul1001
pushed a commit
that referenced
this pull request
Oct 20, 2026
…on test (#75175) (#75181) test_promotion_leaves_earlier_placeholder_task_instances_at_their_coordinates asserted that the archived -1 attempt of a mapped task survives expansion. Since #74407 expansion deletes those attempts, but the delete runs with synchronize_session=False, so session.get() kept returning the stale identity-map object and the test passed while asserting the opposite of what the database holds. Expire the session and query the database, asserting the archived placeholder attempt is gone, and rename the test to match. (cherry picked from commit 11ed204) Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
vatsrahul1001
pushed a commit
that referenced
this pull request
Oct 20, 2026
…ta is present (#74407) The 0142 downgrade refused whenever xcom_v2 or rtif_v2 held rows or any task had retried since the upgrade, so a rollback after any real use of 3.4 was impossible. It now folds that data back into the legacy tables as if 3.3 had written it. That is only lossless for the latest attempt: the legacy tables are keyed by task coordinates and can hold values for one attempt, so earlier attempts' XCom and rendered fields are dropped while the attempts themselves move back to task_instance_history. The release note records that cost and the runtime, which grows with the size of xcom and rendered_task_instance_fields. Data 3.3 cannot represent (several attempts sharing coordinates, archived attempts with no current attempt, owners that moved while legacy rows exist) is refused by read-only checks before the first write, because MySQL cannot roll back DDL. Past that point a failure on MySQL leaves the schema partly downgraded and needs a restore from backup. The downgrade leaves try_number alone. Migration 0138's downgrade already subtracts one from pending retries and runs after this one on any downgrade to 3.3, so rewinding here as well made a retried task reuse an archived try number. Only a test that downgrades through 0138 can see it. Expansion now deletes the archived attempts of an unmapped task instance. Once it is promoted or removed they have no current attempt, and a cleared mapped task would make every later downgrade refuse. The delete is scoped to the placeholder's own region so expanding one loop pass cannot remove a sibling pass's archived attempts. It discards real earlier runs of a task that later became mapped. (cherry picked from commit a87c6dd)
vatsrahul1001
pushed a commit
that referenced
this pull request
Oct 20, 2026
…on test (#75175) (#75181) test_promotion_leaves_earlier_placeholder_task_instances_at_their_coordinates asserted that the archived -1 attempt of a mapped task survives expansion. Since #74407 expansion deletes those attempts, but the delete runs with synchronize_session=False, so session.get() kept returning the stale identity-map object and the test passed while asserting the opposite of what the database holds. Expire the session and query the database, asserting the archived placeholder attempt is gone, and rename the test to match. (cherry picked from commit 11ed204) Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
Closed
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The downgrade refused whenever XCom_v2 or rendered field data had rows, or
any task retried since the upgrade, so a rollback after any real use of 3.4
was impossible.
This fixes it, as long as the data can be downgraded non-destructively
"as if 3.3 wrote it". This means you might loose data that 3.3 wouldn't
have kept for archived tries.
Document the cost and caveats in the 3.4.0 release notes.
Was generative AI tooling used to co-author this PR?
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.