[Composer][airflow_db_cleanup] - All DAGs runs older than `max_db_entry_age_in_days` are deleted
还没有人认领这个 Issue。
评估
调研方向
从 composer/workflows/airflow_db_cleanup.py 开始,检查 list_dags 和 dag_id 是如何传递给 build_query 的。将显示的更改与链接的 commit 进行比较,并验证清理过程绝不会生成未限定范围的查询;完成的标准是移除较早的运行记录,同时不删除每个 DAG 保留的最新运行记录。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Jupyter Notebook
- 星标
- 8.1k
- 派生
- 6.7k
- 平均合并
- 4 天 4 小时
- 30 天内合并 PR
- 8
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
GoogleCloudPlatform/python-docs-samples 的其他 Issue
-
samples
难度 2/5 1-3 小时 新手友好度 88/100
-
samples
难度 1/5 1 小时以内 新手友好度 92/100
-
samples
难度 2/5 1-3 小时 新手友好度 88/100
-
samples
GoogleCloudPlatform/python-docs-samples#14117 · 已指派 1 人 ·
-
samples
GoogleCloudPlatform/python-docs-samples#14091 · 已指派 1 人 ·
查看 GoogleCloudPlatform/python-docs-samples 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 88/100
TencentCloud/Octop#1157 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 86/100
-
backend bug
难度 2/5 1-3 小时 新手友好度 68/100
nolte/kamerplanter#1802 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
drogonframework/drogon#2605 ·