hliu-VoleonGroup opened a new issue, #35415:
URL: https://github.com/apache/airflow/issues/35415

   ### Apache Airflow version
   
   main (development)
   
   ### What happened
   
   - The execution date in a triggered SLA alert is one schedule interval ahead 
of the expected one. 
   
   - In other words, the execution date of the SLA record inserted into the 
`SlaMiss` table is incorrect.
   
   - For example, if a daily task with an execution date `2023-10-23 21:00:00` 
triggers an SLA alert, the execution date in that alert will be `2023-10-24 
21:00:00` rather than `2023-10-23 21:00:00`.
   
   ### What you think should happen instead
   
   _No response_
   
   ### How to reproduce
   
   1. Create a simple DAG scheduled every 5 minutes
   
   ```
   import datetime
   from airflow.models import DAG
   from airflow.operators.bash import BashOperator
   
   DEFAULT_ARGS = {
       "owner": "test",
       "email": ["t...@email.com"]
   }
   
   dag = DAG(
       dag_id="test_dag",
       schedule_interval="*/5 * * * *",
       start_date=datetime.datetime(2023, 10, 20),
       catchup=False
   )
   
   with dag:
     task = BashOperator(
         task_id="task",
         bash_command="sleep 120; dummy command",
         sla=datetime.timedelta(minutes=1))
   ```
   
   2. Enable the DAG and mark its first dagrun with execution date T as success.
   3. Its second dagrun with execution date T+5 should fail and trigger an SLA 
alert at T + 11 (T + 5 + 5 + 1).
        However, the execution date of the task in this alert will be T + 10 
instead of T + 5, which is not correct.
   4. Also, the SLA record in the `SlaMiss` table has a wrong execution date as 
well.
   
   ### Operating System
   
   CentOS Linux 7
   
   ### Versions of Apache Airflow Providers
   
   apache-airflow-providers-common-sql==1.8.0
   apache-airflow-providers-ftp==3.6.0
   apache-airflow-providers-http==4.6.0
   apache-airflow-providers-imap==3.4.0
   apache-airflow-providers-sqlite==3.5.0
   
   ### Deployment
   
   Other Docker-based deployment
   
   ### Deployment details
   
   _No response_
   
   ### Anything else
   
   I have submitted a PR to apache-airflow repository for fixing this issue.
   https://github.com/apache/airflow/pull/35389
   It would be great if someone could take a look.
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to