Skip to content

Include serialized_dag table in airflow db clean - #72912

Closed
wolvery wants to merge 2 commits into
apache:mainfrom
wolvery:clean-serialized-dag-table
Closed

wolvery wants to merge 2 commits into
apache:mainfrom
wolvery:clean-serialized-dag-table

Conversation

@wolvery

@wolvery wolvery commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Include serialized_dag in airflow db clean table configurations.

In Airflow 3, SerializedDagModel stores serialized definitions per DagVersion, accumulating JSON and binary data over time. Previously, serialized_dag was omitted from db clean, preventing operators from purging unreferenced historical serialized DAG records.

This change:

  • Adds serialized_dag to config_list in db_cleanup.py with recency tracking on created_at and version reference checks.
  • Sets keep_last=True grouped by dag_id to preserve the latest serialized DAG definition.
  • Adds serialized_dag to dag_version dependent tables so serialized records and cascading deadline_alert rows are cleaned and archived before version records.
  • Adds unit tests covering retention, pruning, cascading, and CLI DAG ID filtering.

Was generative AI tooling used to co-author this PR?
  • Yes — Gemini 3.8

Generated-by: Gemini 3.8 following the guidelines

In Airflow 3, SerializedDagModel stores serialized definitions per DagVersion, accumulating large JSON and binary blobs as DAG versions evolve. Previously, serialized_dag was not included in db clean table configurations, preventing operators from purging unreferenced historical serialized DAG records and cascading deadline alerts.

@zozo123 zozo123 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.

LGTM. Deferring to maintainers for final 👍

recency_column_name="created_at",
extra_columns=["id"],
dependent_tables=["task_instance", "dag_run"],
dependent_tables=["task_instance", "dag_run", "serialized_dag"],

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.

great catch!

@shahar1

shahar1 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Include serialized_dag in airflow db clean table configurations.

In Airflow 3, SerializedDagModel stores serialized definitions per DagVersion, accumulating JSON and binary data over time. Previously, serialized_dag was omitted from db clean, preventing operators from purging unreferenced historical serialized DAG records.

This change:

  • Adds serialized_dag to config_list in db_cleanup.py with recency tracking on created_at and version reference checks.
  • Sets keep_last=True grouped by dag_id to preserve the latest serialized DAG definition.
  • Adds serialized_dag to dag_version dependent tables so serialized records and cascading deadline_alert rows are cleaned and archived before version records.
  • Adds unit tests covering retention, pruning, cascading, and CLI DAG ID filtering.
Was generative AI tooling used to co-author this PR?
  • Yes — Gemini 3.8

Generated-by: Gemini 3.8 following the guidelines

May I ask what Airflow version do you use? (it might been solved by #68339, release in v3.3.0)

@wolvery

wolvery commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

Closing because #68339 already implements the correct cleanup path through dag_version. Deleting serialized_dag independently could leave a DagVersion without its serialized definition.


Drafted-by: GitHub Copilot (GPT-5.6) (no human review before posting)

@wolvery wolvery closed this Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants