Reserialize Dags when downgrading below 3.1.0 #55981
Closed
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.
Downgrading to Airflow ≤3.0.x could leave the metadata DB with serializer v3 Dags that older versions cannot read or reserialize. This change automatically reserializes Dags to a compatible serializer version after a successful airflow db downgrade.
On downgrade, we map the target Airflow version to a serializer version and reserialize all DAGs (skipped for --show-sql-only). The mapping is derived from a new _SER_DAG_VERSIONS_MAP, resolved from either --to-version or --to-revision.
Adds db.reserialize_all_dags_to_serializer_version supporting 3→2 down-conversion. It performs a SQL fast-path for uncompressed rows across the db types and falls back to row-wise updates for compressed rows. The function does not commit and logs warnings instead of failing the CLI.
Tests cover triggering on --to-version, skipping with --show-sql-only, and the --to-revision path.
User impact: Downgrading to 3.0.x no longer results in incompatible v3-serialized Dags; the scheduler/UI can read Dags immediately after the downgrade.