Skip to content

fix(db_cleanup): remove invalid dag_id column for task_reschedule - #72023

Open
waterWang wants to merge 1 commit into
apache:mainfrom
waterWang:fix/db-cleanup-task-reschedule-dag-id
Open

fix(db_cleanup): remove invalid dag_id column for task_reschedule#72023
waterWang wants to merge 1 commit into
apache:mainfrom
waterWang:fix/db-cleanup-task-reschedule-dag-id

Conversation

@waterWang

Copy link
Copy Markdown

The TaskReschedule table was migrated in Airflow 3.0 (migration 0063) from dag_id/task_id/run_id to ti_id (UUID FK to task_instance.id). The dag_id column was dropped.

However, db_cleanup.py's _TableConfig for task_reschedule still specified dag_id_column_name="dag_id", causing the _build_query function to generate:

SELECT count(*) FROM (SELECT base.* FROM task_reschedule AS base
WHERE base.start_date < ... AND base.dag_id IN (...)) AS anon_1

This fails with column base.dag_id does not exist on PostgreSQL (and similar errors on other databases) when airflow db clean is run with a --dag-id filter.

Fix: Remove the dag_id_column_name from task_reschedule's config, since the table no longer has a dag_id column and cannot be directly filtered by DAG ID.

Other tables without a dag_id column (e.g., import_error, callback_request, trigger, celery_taskmeta) already omit this parameter — this fix makes task_reschedule consistent with them.

Fixes #72020

TaskReschedule table was migrated in Airflow 3.0 (migration 0063)
to use ti_id (FK to task_instance.id) instead of dag_id/task_id/run_id.
The dag_id column was dropped. db_cleanup.py still referenced it,
causing "column base.dag_id does not exist" errors when running
`airflow db clean` with --dag-id filter.

Fixes apache#72020
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.

Failed queries in Postgres Logs

1 participant