[英]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.