[Composer][airflow_db_cleanup] - All DAGs runs older than `max_db_entry_age_in_days` are deleted
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 55/100
Research direction
Start in composer/workflows/airflow_db_cleanup.py and inspect how list_dags and dag_id are passed to build_query. Compare the shown change with the linked commit and verify the cleanup never produces an unscoped query; done means older runs are removed without deleting every DAG's retained latest run.
Written by the indexing model from the issue text.
Description
In which file did you encounter the issue?
composer/workflows/airflow_db_cleanup.py
Did you change the file? If so, how?
dags = session.query(airflow_db_model.dag_id).distinct()
session.commit()
- list_dags = [str(list(dag)[0]) for dag in dags] + [None]
+ list_dags = [str(list(dag)[0]) for dag in dags]
for dag_id in list_dags:
query = build_query(
session=session,
Describe the issue
Since this commit which removed a check on whether dag_id argument is None, running the airflow_db_cleanup DAG will result in deleting all DAGs runs older than max_db_entry_age_in_days across all DAG IDs without keeping the at least the latest run for each DAG.
As shown in the logs for the final iteration [None] this generates the following query:
[2025-09-19T13:24:14.981+0000] {airflow_db_cleanup.py:378} INFO - Query: SELECT dag_run.state AS dag_run_state, dag_run.id AS dag_run_id, dag_run.dag_id AS dag_run_dag_id, dag_run.queued_at AS dag_run_queued_at,
dag_run.execution_date AS dag_run_execution_date, dag_run.start_date AS dag_run_start_date, dag_run.end_date AS dag_run_end_date, dag_run.run_id AS dag_run_run_id, dag_run.creating_job_id AS dag_run_creating_job_id,
dag_run.external_trigger AS dag_run_external_trigger, dag_run.run_type AS dag_run_run_type, dag_run.conf AS dag_run_conf, dag_run.data_interval_start AS dag_run_data_interval_start,
dag_run.data_interval_end AS dag_run_data_interval_end, dag_run.last_scheduling_decision AS dag_run_last_scheduling_decision, dag_run.dag_hash AS dag_run_dag_hash,
dag_run.log_template_id AS dag_run_log_template_id, dag_run.updated_at AS dag_run_updated_at, dag_run.clear_number AS dag_run_clear_number
FROM dag_run
WHERE dag_run.execution_date <= %(execution_date_1)s
- Dominant language
- Jupyter Notebook
- Stars
- 8.1k
- Forks
- 6.7k
- Avg merge
- 4d 4h
- Merged PRs (30d)
- 8
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from GoogleCloudPlatform/python-docs-samples
-
samples
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
GoogleCloudPlatform/python-docs-samples#14609 ·
Maintainers usually reply within 1 day
-
samples
Difficulty 1/5 Under an hour Newbie friendliness 92/100
GoogleCloudPlatform/python-docs-samples#14610 ·
Maintainers usually reply within 1 day
-
samples
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
GoogleCloudPlatform/python-docs-samples#14611 ·
Maintainers usually reply within 1 day
-
chore(generative_ai) Update model references for generative_ai samplesMay be free again @XrossFox claimed this 152 days ago, and no pull request is open. Opensamples
GoogleCloudPlatform/python-docs-samples#14117 · 1 assignee ·
Maintainers usually reply within 1 day
-
Fix Pipeline dependency issues for geospatial-classification/serving_appMay be free again @XrossFox claimed this 164 days ago, and no pull request is open. Opensamples
GoogleCloudPlatform/python-docs-samples#14091 · 1 assignee ·
Maintainers usually reply within 1 day
All issues in GoogleCloudPlatform/python-docs-samples
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
openfoodfacts/openfoodfacts-server#14724 ·
Maintainers usually reply within 1 day
-
bug P2 reliability
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
afreidah/s3-orchestrator#1564 ·
Maintainers usually reply within 1 day
-
Bug Report: `sqltypes.EncodeStringSQL` rewrites invalid UTF-8 bytes in string literals as `U+FFFD`OpenComponent: Query Serving Needs Triage Type: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
firebase/firebase-ios-sdk#16718 ·
Maintainers usually reply within 1 day