Apache 气流:将追赶设置为 False 不起作用

dha*_*eme 9 scheduler airflow

我在 Apache 气流上创建了一个 DAG。似乎调度程序配置为从 2015 年 6 月开始运行它(顺便说一句。我不知道为什么,但它是一个新创建的 DAG,我没有回填它,我只用这些回填了具有不同 DAG ID 的其他 dag日期间隔,调度程序采用这些日期并填充我的新 dag。我开始使用气流)。

(更新:我意识到 DAG 是回填的,因为开始日期是在 DAG 默认配置上设置的,尽管这并不能解释我在下面公开的行为)

我正在尝试停止调度程序以从该日期开始运行所有 DAG 执行。airflow backfill --mark_success tutorial2 -s '2015-06-01' -e '2019-02-27'命令给我数据库错误(见下文),所以我试图将追赶设置为 False。

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) 没有这样的表:job [SQL: 'INSERT INTO job (dag_id, state, job_type, start_date, end_date, latest_heartbeat, executor_class, hostname, unixname) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'] [参数: ('tutorial2', 'running', 'BackfillJob', '2019-02-27 10:52:37.281716', None, '2019-02- 27 10:52:37.281733', 'SequentialExecutor', '08b6eb432df9', 'airflow')](此错误的背景:http ://sqlalche.me/e/e3q8 )

所以我正在使用另一种方法。我试过的:

  1. 在airflow.cfg 中设置catchup_by_default = False 并重新启动整个docker 容器。
  2. 在我的 pyhton DAG 文件上设置 catchup = False 并再次使用 python 启动文件。

我在网络用户界面上看到的:

DAG 的执行将从 2015 年 6 月开始: DAG 的执行将从 2015 年 6 月开始。 Catchup 在 DAG 的配置上设置为 False:

Catchup 在 DAG 的配置上设置为 False 所以我不明白为什么要启动那些 DAG 的执行。

谢谢

DAG代码:

"""
Code that goes along with the Airflow tutorial located at:
https://github.com/apache/airflow/blob/master/airflow/example_dags/tutorial.py
"""
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import datetime, timedelta


default_args = {
    'owner': 'airflow',
    'depends_on_past': False,
    'start_date': datetime(2015, 6, 1),
    'email': ['airflow@example.com'],
    'email_on_failure': False,
    'email_on_retry': False,
    'retries': 1,
    'retry_delay': timedelta(minutes=5),
    'catchup' : False,
    # 'queue': 'bash_queue',
    # 'pool': 'backfill',
    # 'priority_weight': 10,
    # 'end_date': datetime(2016, 1, 1),
}

dag = DAG(
    'tutorial2', default_args=default_args, schedule_interval='* * * * *')

# t1, t2 and t3 are examples of tasks created by instantiating operators
t1 = BashOperator(
    task_id='print_date',
    bash_command='date',
    dag=dag)

t2 = BashOperator(
    task_id='sleep',
    bash_command='sleep 5',
    retries=3,
    dag=dag)

templated_command = """
    {% for i in range(5) %}
        echo "{{ ds }}"
        echo "{{ macros.ds_add(ds, 7)}}"
        echo "{{ params.my_param }}"
    {% endfor %}
"""

t3 = BashOperator(
    task_id='templated',
    bash_command=templated_command,
    params={'my_param': 'Parameter I passed in'},
    dag=dag)

t2.set_upstream(t1)
t3.set_upstream(t1)
Run Code Online (Sandbox Code Playgroud)

san*_*ton 9

我认为您实际上需要在dag级别指定追赶,而不是通过default_args. (无论如何,后者实际上没有意义,因为这些是任务的默认参数。您不能让某些任务赶上而其他任务则不能。)

尝试这个:

dag = DAG(
    'tutorial2', default_args=default_args, schedule_interval='* * * * *', catchup=False)
Run Code Online (Sandbox Code Playgroud)

  • 谢谢,它似乎有效,尽管仍有一个未解决的问题。未正确应用airflow.cfg 文件默认配置中的配置。 (3认同)