airflow icon indicating copy to clipboard operation
airflow copied to clipboard

SLA Misses not being recorded

Open matthewdavidhauser opened this issue 10 years ago • 3 comments

Airflow v1.6.1 For our DAGs which run daily we aren't seeing any SLA misses being recorded when the SLA is missed

I think the issue is here:

for ti in max_tis:
    task = dag.get_task(ti.task_id)
    dttm = ti.execution_date
    if task.sla:
        dttm = dag.following_schedule(dttm)
        following_schedule = dag.following_schedule(dttm)
        while dttm < datetime.now():
            if following_schedule + task.sla < datetime.now():
                session.merge(models.SlaMiss(
                    task_id=ti.task_id,
                    dag_id=ti.dag_id,
                    execution_date=dttm,
                    timestamp=ts))
            dttm = dag.following_schedule(dttm)

Lets say our DAG runs daily and today is 2016-01-06 (execution_date 2016-01-05T00:00) and that yesterday 2016-01-05 (execution_date 2016-01-04T00:00) ran successfully. This would imply that for today's run, we would have the following walk through:

  1. dttm = 2016-01-05T00:00
  2. dttm = 2016-01-06T00:00
  3. following_schedule = 2016-01-07T00:00 So following_schedule + task.sla < datetime.now() will always be false (unless the task takes more than the schedule interval (24 hours) and the SLA time to complete. I think we should instead just have if dttm + task.sla < datetime.now():

matthewdavidhauser avatar Jan 06 '16 18:01 matthewdavidhauser

+1 :)

joenap avatar Jan 06 '16 18:01 joenap

I think there's a bug there but I'm not sure that it's what you describe.

The behavior we want is if SLA is 1 hour, we should error for the 2016-01-01 run at 2016-01-02T01:00:00 since the 2016-01-01 run can't start before 2016-01-02.

One problem I see is that following_schedule = dag.following_schedule(dttm) should be in the while loop.

mistercrunch avatar Jan 06 '16 23:01 mistercrunch

https://github.com/airbnb/airflow/pull/840

mistercrunch avatar Jan 06 '16 23:01 mistercrunch