Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate pickled data & change XCom value type to JSON #44166

Merged
merged 3 commits into from
Nov 19, 2024

Conversation

kaxil
Copy link
Member

@kaxil kaxil commented Nov 18, 2024

follow-up of #43905

Changes:

  • Changed XCom.value column to JSON for all dbs.
  • Archived pickled XCom data to _xcom_archive and removed it from the xcom table.
  • Removed encoded string in XCom serialization and deserialization logic.
  • Updated logic for XComObjectStorageBackend to make it compatible for AF 2 & 3
image

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@kaxil kaxil added the airflow3.0:breaking Candidates for Airflow 3.0 that contain breaking changes label Nov 18, 2024
@kaxil kaxil mentioned this pull request Nov 18, 2024
Copy link
Member

@ashb ashb left a comment

Choose a reason for hiding this comment

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

I don't love the migration, but it seems "safe" enough (modulo the comment about hex() call on mysql path, and I can't think of a better approach either)

@kaxil kaxil requested a review from ashb November 19, 2024 14:50
- Changed `XCom.value` column to JSON for all dbs.
- Archived pickled XCom data to `_xcom_archive` and removed it from the `xcom` table.
- Removed encoded string in XCom serialization and deserialization logic.
@kaxil kaxil merged commit 86c4c6f into apache:main Nov 19, 2024
62 of 63 checks passed
@kaxil kaxil deleted the xcom-migration branch November 19, 2024 15:56
@kaxil
Copy link
Member Author

kaxil commented Nov 19, 2024

Static failure is unrelated

@jscheffl
Copy link
Contributor

Thanks for the PR - I LIKE it! Sorry entering too late for review :-(

kaxil added a commit to astronomer/airflow that referenced this pull request Nov 22, 2024
This tables was created to not cause data loss (in apache#44166) when upgrading from AF 2 to AF 3 if a user had pickled values in XCom table.

- Introduced `ARCHIVED_TABLES_FROM_DB_MIGRATIONS` to track tables created during database migrations, such as `_xcom_archive`.
- Added `_xcom_archive` to the db cleanup `config_list` for handling its records based on `timestamp`.
- Add support in `airflow db drop-archived` to drop `_xcom_archive`.
kaxil added a commit that referenced this pull request Nov 22, 2024
This tables was created to not cause data loss (in #44166) when upgrading from AF 2 to AF 3 if a user had pickled values in XCom table.

- Introduced `ARCHIVED_TABLES_FROM_DB_MIGRATIONS` to track tables created during database migrations, such as `_xcom_archive`.
- Added `_xcom_archive` to the db cleanup `config_list` for handling its records based on `timestamp`.
- Add support in `airflow db drop-archived` to drop `_xcom_archive`.
kaxil pushed a commit that referenced this pull request Dec 3, 2024
In [PR](#44166) we added migration for removing pickled data from `xcom` table. During my testing I noticed with `SQLite`  [insert](https://github.com/apache/airflow/blob/main/airflow/migrations/versions/0049_3_0_0_remove_pickled_data_from_xcom_table.py#L88) statement is not working in case of upgrade. Changing condition to `hex(substr(value, 1, 1)) = '80'` works. Tested [here](#44533 (comment)).

related: #44166
LefterisXefteris pushed a commit to LefterisXefteris/airflow that referenced this pull request Jan 5, 2025
follow-up of apache#43905

Changes:
- Changed `XCom.value` column to JSON for all dbs.
- Archived pickled XCom data to `_xcom_archive` and removed it from the `xcom` table.
- Removed encoded string in XCom serialization and deserialization logic.
- Updated logic for `XComObjectStorageBackend` to make it compatible for AF 2 & 3
LefterisXefteris pushed a commit to LefterisXefteris/airflow that referenced this pull request Jan 5, 2025
This tables was created to not cause data loss (in apache#44166) when upgrading from AF 2 to AF 3 if a user had pickled values in XCom table.

- Introduced `ARCHIVED_TABLES_FROM_DB_MIGRATIONS` to track tables created during database migrations, such as `_xcom_archive`.
- Added `_xcom_archive` to the db cleanup `config_list` for handling its records based on `timestamp`.
- Add support in `airflow db drop-archived` to drop `_xcom_archive`.
LefterisXefteris pushed a commit to LefterisXefteris/airflow that referenced this pull request Jan 5, 2025
In [PR](apache#44166) we added migration for removing pickled data from `xcom` table. During my testing I noticed with `SQLite`  [insert](https://github.com/apache/airflow/blob/main/airflow/migrations/versions/0049_3_0_0_remove_pickled_data_from_xcom_table.py#L88) statement is not working in case of upgrade. Changing condition to `hex(substr(value, 1, 1)) = '80'` works. Tested [here](apache#44533 (comment)).

related: apache#44166
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
airflow3.0:breaking Candidates for Airflow 3.0 that contain breaking changes area:db-migrations PRs with DB migration kind:documentation
Development

Successfully merging this pull request may close these issues.

3 participants