Skip to content

Clarify db downgrade rollback limits - #69645

Closed
Muhtasim-Munif-Fahim wants to merge 1 commit into
apache:mainfrom
Muhtasim-Munif-Fahim:codex/airflow-downgrade-serde-docs
Closed

Muhtasim-Munif-Fahim wants to merge 1 commit into
apache:mainfrom
Muhtasim-Munif-Fahim:codex/airflow-downgrade-serde-docs

Conversation

@Muhtasim-Munif-Fahim

Copy link
Copy Markdown

Summary

  • add a rollback warning to the upgrade guide explaining that backups are the only clean rollback path once a newer Airflow version has written incompatible metadata rows
  • add a matching warning to the db downgrade CLI docs explaining that the command only reverts Alembic schema changes

Testing

  • git diff --check
  • python -m docutils --report=5 --exit-status=4 airflow-core/docs/howto/usage-cli.rst NUL
  • python -m docutils --report=5 --exit-status=4 airflow-core/docs/installation/upgrading.rst NUL

Closes #68317

@boring-cyborg

boring-cyborg Bot commented Jul 9, 2026

Copy link
Copy Markdown

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 Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: [email protected]
    Slack: https://s.apache.org/airflow-slack

@potiuk potiuk added the ready for maintainer review Set by triage when all criteria pass, or by the fork CI reconciler when fork CI is green. label Jul 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions Bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Aug 30, 2026

@Eason09053360 Eason09053360 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch! This is my perspective and a few suggestion. Feel free to resolve it.

Comment on lines +328 to +331
``db downgrade`` only reverts schema changes tracked by Alembic. It does not rewrite metadata rows
that were already written by the newer Airflow version into an older serialization format. If the
newer version has already run against the database, restoring a metadata DB backup taken before the
upgrade is the only clean rollback path.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"If the newer version has already run against the database" covers almost every real downgrade, so this reads as "db downgrade is never clean". It might also conflicts with the dags reserialize note at the end of this section. Making it conditional keeps both true, and naming the error helps people searching for it.

Suggested change
``db downgrade`` only reverts schema changes tracked by Alembic. It does not rewrite metadata rows
that were already written by the newer Airflow version into an older serialization format. If the
newer version has already run against the database, restoring a metadata DB backup taken before the
upgrade is the only clean rollback path.
``db downgrade`` runs the Alembic downgrade migrations. They revert schema changes, but convert only
the data they were written to convert. Anything else the newer Airflow version wrote in a format the
older version cannot read stays as it is. For example, Airflow 3.1 cannot read trigger kwargs written
by Airflow 3.2 and fails with ``KeyError: '__var'``. In such cases, restoring a metadata DB backup
taken before the upgrade is the only clean rollback path.

Comment on lines +45 to +48
Backups are also the only clean rollback path when a newer Airflow version has already written
metadata rows in a format that an older version cannot read. ``airflow db downgrade`` only
reverts Alembic schema migrations; it does not rewrite existing metadata row content back to an
older serialization format.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same correction here, plus the concrete 3.2 → 3.1 case from the issue.

Suggested change
Backups are also the only clean rollback path when a newer Airflow version has already written
metadata rows in a format that an older version cannot read. ``airflow db downgrade`` only
reverts Alembic schema migrations; it does not rewrite existing metadata row content back to an
older serialization format.
Backups are also the only clean rollback path when a newer Airflow version has already written
metadata in a format that an older version cannot read. ``airflow db downgrade`` reverts schema
changes, but its downgrade migrations convert only the data they were written to convert. For
example, Airflow 3.1 cannot read trigger kwargs written by Airflow 3.2, even after
``airflow db downgrade`` succeeds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:CLI kind:documentation ready for maintainer review Set by triage when all criteria pass, or by the fork CI reconciler when fork CI is green. stale Stale PRs per the .github/workflows/stale.yml policy file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document that airflow db downgrade from 3.2 to 3.1.x does not revert SDK-serialized metadata row content

3 participants