简体   繁体   English

气流 dag 不止一次被触发

[英]airflow dag getting triggered more than once

I have a dag with one task, and I want it to get triggered only once a day.我有一个任务,我希望它每天只触发一次。 My problem is that it gets triggered multiple times when the time comes.我的问题是它在时机成熟时被多次触发。 So the daily task is run 4 times instead of once.所以每日任务运行 4 次而不是一次。 I set a number of configurations to fix that including:我设置了许多配置来解决这个问题,包括:

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

I also increased the time between retires thinking maybe airflow thinks the task has failed/not started since it might take some time for task to finish.我还增加了退休之间的时间,认为气流可能认为任务失败/未开始,因为任务可能需要一些时间才能完成。

I also moved all the code that is supposed to run in that dag to utils folder based on this answer我还根据此答案将应该在该 dag 中运行的所有代码移动到 utils 文件夹

But I don't know what am I missing here.但我不知道我在这里错过了什么。 Can anyone please help?任何人都可以帮忙吗? Thank you in advance.先感谢您。

Here is the dag这是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)

If your goal is to run the job once per day at 7PM (1900) then your schedule_interval is incorrect.如果您的目标是每天晚上 7 点 (1900) 运行一次作业,那么您的schedule_interval是不正确的。 You want 0 19 * * * .你想要0 19 * * *

In the Airflow documentation their examples for schedule_intervals consist of 5 space separated elements: https://airflow.apache.org/docs/apache-airflow/1.10.1/scheduler.html#dag-runs .在 Airflow 文档中,他们的schedule_intervals示例由 5 个空格分隔的元素组成: https : //airflow.apache.org/docs/apache-airflow/1.10.1/scheduler.html#dag-runs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何运行超过 10 万个任务的 Airflow dag? - How to run Airflow dag with more than 100 thousand tasks? 将 Airflow 触发的 DAG 标记为失败/成功会影响 DAG 的所有运行 - Mark Failed/Success for Airflow triggered DAG effects all runs of the DAG 如何使用 Airflow 变量为 DAG 动态运行多个作业 - How to use Airflow variables to run more than one Job for a DAG dynamically Airflow:区分 API 和 UI 触发的 dag 运行 - Airflow: distinguish API- and UI-triggered dag runs Airflow DAG 正在运行但未执行任务 - Airflow DAG is running but tasks not getting executed 我可以使用 TriggerDagRunOperator 将参数传递给触发的 dag 吗? Airflow - Can I use a TriggerDagRunOperator to pass a parameter to the triggered dag? Airflow Airflow 2.0.0+ - 将动态生成的字典传递给由 TriggerDagRunOperator 触发的 DAG - Airflow 2.0.0+ - Pass a Dynamically Generated Dictionary to DAG Triggered by TriggerDagRunOperator Airflow - BashOperator:获取“Dag 运行已为 DAG 死锁:...”错误 - Airflow - BashOperator: Getting “Dag runs are deadlocked for DAG:..” error Google Cloud Composer DAG 未触发 - Google Cloud Composer DAG is not getting triggered 调用函数后,GCP Composer / Airflow无法识别DAG - GCP Composer/Airflow fails to recognise DAG once function is called
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM