I don’t understand why SLA’s sometimes are triggered.
An example is a dag with an SLA of 'sla': timedelta(hours=1)
I received an email with this:
Here’s a list of tasks that missed their SLAs:
APP_task_group.copy_events on 2022-05-08T03:00:00+00:00
But checking the graph view in the UI I see it started at 04:28 and finished at 04:46, which is range of one hour.
I understand that the SLA is starting in the real UTC time when the dag starts, so the dag with id 2022-05-08T03:00:00+00:00 has between 04:00 and 04:59 UTC to run without raising an SLA.
Am I wrong?
What does explain why this SLA is raising?
Related
I am completely new to Airflow and am trying to grasp the concepts of scheduling and default args.
I have a scenario where I would like to schedule my DAG hourly to do some data transfer task between a source and a database. What I am trying to understand is, lets say one of my DAG runs has triggered at 00:00 AM. Now if it takes more than an hour for this run to successfully complete all of its tasks (say 1 hour 30 min), does it mean that the next DAG run that was supposed to be triggered at 01:00 AM will NOT get triggered but the DAG run from 02:00 AM will get triggered?
Yes.
In order to avoid, you need catchup=True for the DAG object.
Reference : https://airflow.apache.org/docs/apache-airflow/stable/dag-run.html
(Search for Catchup)
Airflow Scheduler used to monitor all DAGs and tasks in Airflow.Default Arguments can be used to create tasks with default parameters in DAG.
The first DAG runs based on start_date and runs based on scheduled_interval sequentially. Scheduler doesn’t trigger tasks until the period has ended.For your requirement you can set dag.catchup to true as to run the DAG for each completed interval and scheduler will execute them sequentially.Catchup is used to start the DAG run since the last data interval which has not started for any data interval.
I am trying to define periods of time where the scheduler will not mark tasks as ready.
For example, I have a DAG with a lengthy backfill period. The execution of the backfill will run throughout the day until the DAG is caught up. However I do not want and executions of the DAG to execute between midnight and 2 am.
Is it possible to achieve this through configuration?
After pausing a dag for 2-3 days, when resuming the dag with catchup=False, will run immediately with the last execution.
For example a dag that sends data to an external system is scheduled to run everyday on 19:00.
Stopping the dag for 4 days and enabling on 11:00 would run the dag immediately with yesterdays execution and then again on 19:00 for that day.
In this case the dag runs two times on the day it's resumed.
Is it possible to resume the dag and the first run will happen actually on 19:00?
With default operators, we cannot achieve what you are expecting. Closest to that, what airflow has is LatestOnlyOperator. This is one of the simplest Operators and needs only following configuration
latest_only = LatestOnlyOperator(task_id='latest_only')
This would let the downstream tasks run only if the current time falls between current execution date and next execution date. So, in your case, it would skip execution of three days, but yesterday's run would trigger the jobs.
Some of our DAGs are scheduled to run once per minute for the first 5 minutes of a given hour. For example, the DAG might run at:
20:01
20:02
20:03
20:04
20:05
Most of the time this works fine, but some of the time an entire DAG run is missing. For example, the DAG might run at:
20:01
20:03
20:04
20:05
We have verbose logging turned on, but I don't see anything in the Scheduler logs at 20:02 that obviously explains why the DAG never ran. I also don't see prolonged DAG parsing time that other issues point to as the potential culprit:
Number of DAGs: 177
Total task number: 259
DagBag parsing time: 7.171621999999997
The database resource utilization is minimal, which also is sometimes pointed to as a culprit.
If anyone has ideas of how to approach this problem or hypotheses as to what might cause a DAG not to run at a given 1 minute interval, but run fine at the next 1 minute interval please let me know. Or if you have advice as to what you'd expect to see in the Scheduler logs when it never schedules a DAG, that would he helpful.
I have an airflow dag specified as shown in the picture above.
The git_pull_datagenerator_batch_2 is supposed to be delayed by the TimeDeltaSensor wait_an_hour.
However, the task git_pull_datagenerator seems to be delayed as well although it does not have a dependency on wait_an_hour. (The whole dag is scheduled at 2019-12-10T20:00:00, but git_pull_datagenerator started one hour later than that)
I have checked all documents of airflow but could not find any clues.
I'm assuming your schedule interval is hourly? A DAG run with an execution date of 2019-12-10T20:00:00 on an #hourly schedule interval is expected to run at or shortly after 2019-12-10T21:00:00 when hour 20 has "completed". I don't think it has anything to do with the sensor.
This is a common Airflow pitfall:
Airflow was developed as a solution for ETL needs. In the ETL world,
you typically summarize data. So, if I want to summarize data for
2016-02-19, I would do it at 2016-02-20 midnight GMT, which would be
right after all data for 2016-02-19 becomes available.
If this is what is happening, wait_an_hour started at 2019-12-10T21:00:00 and git_pull_datagenerator_batch_2 at 2019-12-10T22:00:00.
It turns out that the default executor is a SequentialExecutor, which causes all of the tasks to run in a linear order.