Skip to content

fix: skip scheduling for stale DAGs to prevent scheduler failures whe… - #55126

Closed
vikrantkumar-max wants to merge 1 commit into
apache:mainfrom
vikrantkumar-max:fix/54932-airflow-scheduler-fails
Closed

vikrantkumar-max wants to merge 1 commit into
apache:mainfrom
vikrantkumar-max:fix/54932-airflow-scheduler-fails

Conversation

@vikrantkumar-max

Copy link
Copy Markdown
Contributor

closes: #54932

Root Cause

  • DAG removal marks DagModel.is_stale=True but doesn't handle existing task instances
  • Scheduler's _schedule_dag_run() method calls get_dag_for_run() which returns None for removed DAGs
  • Current error handling logs the issue but continues processing, leading to repeated failures

Solution

Added stale DAG detection in _schedule_dag_run() method in scheduler_job_runner.py:

  1. Check for stale DAGs: Added condition if dag_model.is_stale and not dag
  2. Graceful handling: Log warning and skip processing instead of failing
  3. Clean exit: Return immediately to prevent scheduler errors

if dag_model.is_stale and not dag:
self.log.error("DAG %s is stale (removed from filesystem), skipping scheduling for DAG run %s",
dag_run.dag_id, dag_run.run_id)
return callback

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.

Can you share the error you got that resulted in this fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Airflow Scheduler fails with TypeError when trying to fetch dag filepath

2 participants