为什么我的 Airflow DAG 中只有一个 DummyOperator 任务可以 运行?

Why only a DummyOperator task can run in my Airflow DAG?

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

dag_name = 'dagName'

default_args = {
    'owner': 'Airflow',
    'start_date':datetime(2022,2,16),
    'schedule_interval':'@once',
    'retries': 1,
    'retry_delay': timedelta(seconds=5),
    'depends_on_past': False,
    'catchup':False
}

with DAG(dag_name,default_args=default_args) as dag:

    t1 = DummyOperator(task_id="start")

    t2 = BashOperator(task_id='hello_world',
                        bash_command='echo "Hi!!"')
    
    t3 = DummyOperator(task_id="end")
    
    t1 >> t2 >> t3

我在 Apache Airflow 2 上有 运行 这段代码。只有 start 任务标记为成功,而 hello_world 任务仍处于 queued 状态.我检查了任务实例的详细信息,它显示: Task is in the 'queued' state which is not a valid state for execution. The task must be cleared in order to be run. 然后,我清除了 hello_world 任务,但任务仍处于 queued 状态。有什么解决办法吗?谢谢

DummyOperator 没有任何要执行的实际代码,因此将它提交给 worker 的 运行 是多余的,因为 Airflow 已经优化了 DummyOperator 及其任何子类不会被发送给工作人员,它们会被调度程序自动标记为成功(假设没有调用 on_execute_callback 等等)

根据您的描述,您可能有一些配置设置不正确。这不是 DAG 代码问题。