【问题标题】:airflow dag getting triggered more than once气流 dag 不止一次被触发
【发布时间】:2021-11-09 19:28:01
【问题描述】:

我有一个任务,我希望它每天只触发一次。我的问题是它会在时机成熟时多次触发。所以每日任务运行 4 次而不是一次。 我设置了一些配置来解决这个问题,包括:

'retries': 1
 catchup=False, max_active_runs=1

我还增加了退休之间的时间,认为气流可能认为任务已失败/未开始,因为完成任务可能需要一些时间。

我还根据 answer 将应该在该 dag 中运行的所有代码移至 utils 文件夹

但我不知道我在这里错过了什么。有人可以帮忙吗?提前谢谢你。

这里是dag

from datetime import datetime, timedelta
from airflow import DAG
from airflow.operators.python_operator import PythonOperator

from utils.postgres import postgres_backup_to_s3

default_args = {
    'retries': 1,
    'retry_delay': timedelta(minutes=30),#getting backup and uploading to s3 might take some time
    'start_date': datetime(2021, 1, 1)
}

with DAG('postgres_backup', default_args=default_args, schedule_interval='0 19 * * * *',
         catchup=False, max_active_runs=1) as dag:
    postgres_backup_to_s3_task = PythonOperator(task_id="postgres_backup_to_s3", python_callable=postgres_backup_to_s3)

【问题讨论】:

    标签: python airflow airflow-scheduler airflow-api


    【解决方案1】:

    如果您的目标是每天晚上 7 点 (1900) 运行一次作业,那么您的 schedule_interval 不正确。你想要0 19 * * *

    在 Airflow 文档中,schedule_intervals 的示例由 5 个空格分隔的元素组成:https://airflow.apache.org/docs/apache-airflow/1.10.1/scheduler.html#dag-runs

    【讨论】:

    • 您好,感谢您的回复。我更改了格式,现在 dag 没有触发期间。
    猜你喜欢
    • 1970-01-01
    • 2023-03-25
    • 2022-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多