Document that airflow db downgrade does not revert serialized row content - #71984
Open
krishn1301 wants to merge 1 commit into
Open
Document that airflow db downgrade does not revert serialized row content#71984krishn1301 wants to merge 1 commit into
airflow db downgrade does not revert serialized row content#71984krishn1301 wants to merge 1 commit into
Conversation
airflow db downgrade reverses schema migrations only. Rows serialized while the newer version was running keep the newer version's format, and Airflow's compatibility shims run in one direction: 3.2's Trigger._decrypt_kwargs falls back to BaseSerialization when the Task SDK deserializer raises, while 3.1.x calls BaseSerialization directly and has nothing to fall back to. A 3.2-written trigger row therefore crashes 3.1.x with KeyError: <Encoding.VAR: '__var'>, after the downgrade has already reported success. Adds a "Downgrading to an earlier version" section to the upgrade guide covering what the command does and does not revert, the symptom, and the fact that restoring a pre-upgrade backup is the only reliable rollback. Related: apache#68317
|
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
|
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.
Related: #68317
What this documents
airflow db downgradereverses schema migrations. It does not rewrite the contents of rows a newer Airflow already wrote. The upgrade guide currently says nothing about downgrading at all — the word doesn't appear inupgrading.rst— so users reasonably read a successful downgrade as "the database is now compatible with the old version". It isn't.This adds a
Downgrading to an earlier versionsection covering what the command reverts, what it doesn't, the symptom when it bites, and the fact that restoring a pre-upgrade backup is the only reliable rollback.Verification
The interesting part is that Airflow's compatibility shim runs in exactly one direction, which is what turns a downgrade into a crash-loop.
3.1.8 —
Trigger._decrypt_kwargscallsBaseSerializationdirectly, with nothing to fall back to:3.2.1 — the same method reads the Task SDK format first and falls back to the legacy one:
So 3.2 reads 3.1's rows, and 3.1 cannot read 3.2's. The envelopes have no keys in common —
shared/serialization/src/airflow_shared/serialization/__init__.pynames them, and calls the legacy pairOLD_:BaseSerialization.deserializesubscripts that key unguarded atserialized_objects.py:652, which produces theKeyError: <Encoding.VAR: '__var'>from the issue:One correction to the issue as filed
#68317 lists
dag_run.confand "related serialized columns" as affected by the 3.2 serde move. I don't think that part holds.ExtendedJSON— theTypeDecoratorbehinddag_run.conf,taskmap,taskinstanceand friends, and the frame that appears in the reporter's traceback — still usesBaseSerializationin both versions:The serde change is confined to call sites that explicitly import
airflow.sdk.serde, andtrigger.kwargsis the one on this path. I've scoped the docs to trigger kwargs rather than repeating the broader claim. That does leave the reporter's_schedule_all_dag_runsframe unexplained, so if a committer knows of a second 3.2 write path into anExtendedJSONcolumn I'm happy to widen the section.Deliberately not changed
The
airflow db downgradehelp text and the interactive prompt both already say "schema" — accurate, but easy to skim past:I kept this PR to documentation. If you'd like a pointer to the new section added to
cli_config.py'sdescription, say the word and I'll add it here.Newsfragment
Happy to add
{pr}.doc.rstunderairflow-core/newsfragmentsonce this has a number, since the CI check validates the filename against it. Let me know if you want one for a docs-only change.^ Add meaningful description above
Read the Pull Request Guidelines for more information.