You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Airflow DAG未按计划自动触发问题排查求助

DAG未自动触发问题排查分析

问题场景

当前时间为2024年9月1日周日21:45 UTC,目标DAG your_random_dag 按预设调度规则应已触发,但未自动执行,需手动触发才能运行;其余DAG均能按计划正常执行。相关代码如下:

from datetime import timedelta, datetime
from airflow import DAG
from airflow.operators.dummy import DummyOperator
from airflow.operators.bash_operator import BashOperator

default_args = {
    'owner': 'airflow',
    'depends_on_past': False,
    'email': ['abc@abc.com'],
    'email_on_failure': False,
    'email_on_retry': False,
    'start_date': datetime(2024, 8, 26),
    'retries': 1,
    'retry_delay': timedelta(minutes=5),
}

dag = DAG("your_random_dag",
          default_args=default_args,
          schedule_interval='0 21 * * 0',
          dagrun_timeout=None,
          catchup=False,
          )

begin = DummyOperator(dag=dag, task_id="BEGIN")

end = DummyOperator(dag=dag, task_id="END")

t1 = BashOperator(
    task_id="your_random_dag",
    bash_command='python3 /scripts/prod/run_me.py' ,
    dag=dag) 
 
begin >> t1 >> end

核心问题定位

DAG ID与Task ID重复

代码中DAG的ID为 your_random_dag,同时BashOperator的task_id也设置为your_random_dag。Airflow调度逻辑要求DAG与下属Task的ID必须全局唯一,重复ID会导致调度器无法正确识别和触发DAG运行,这是本次自动触发失败的直接原因。

调度规则验证

调度规则 schedule_interval='0 21 * * 0' 表示每周日21:00 UTC触发,当前时间21:45已过触发时间,若无其他阻碍,正常情况下应该已触发,但ID冲突阻断了调度流程。

修复方案

修改BashOperator的task_id,确保与DAG ID不重复,示例代码如下:

t1 = BashOperator(
    task_id="run_prod_script",  # 修改为唯一ID
    bash_command='python3 /scripts/prod/run_me.py' ,
    dag=dag) 

额外排查方向(若修复后仍有问题)

  • 确认Airflow调度器进程处于正常运行状态,未出现挂起或崩溃
  • 检查目标DAG在Airflow UI中处于已启用状态(未被手动暂停)
  • 查看Airflow调度器日志、DAG运行日志,确认是否存在其他错误提示

内容的提问来源于stack exchange,提问作者learner57

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 00:19:55