tirkarthi opened a new pull request, #35984:
URL: https://github.com/apache/airflow/pull/35984

   closes: #35288
   related: #35288 
   
   When a task is deferred then the same attempt is used to queue and resume 
causing the queued_dttm to be greater than start_date for an execution. This 
causes queued duration to be displayed with incorrect value taking queued_dttm 
- start_date which is not correct since start_date should always be greater 
than queued time. Also this causes start offset and to have a fixed queued 
duration bar width of 5. start offset and queued duration min width are shown 
only when queued_dttm is valid by being greater than start_date.
   
   Before patch : (Incorrect queued duration of 23 hours and start of the bar 
is incorrect)
   
   
![gantt_before_patch](https://github.com/apache/airflow/assets/3972343/33295f80-c79d-45ca-a70c-8a9b2480be7b)
   
   After patch : (queued duration is 0 since queued_dttm is greater than 
start_date. start_date position is also correct in gantt as per start_date)
   
   
![gantt_after](https://github.com/apache/airflow/assets/3972343/495c93e1-ca6a-4a85-b3c3-f75fb1215c0a)
   
   
   Sample dag : 
   
   ```python
   from __future__ import annotations
   
   from datetime import datetime
   
   from airflow import DAG
   from airflow.models.baseoperator import BaseOperator
   from airflow.triggers.file import FileTrigger
   
   
   class FileCheckOperator(BaseOperator):
       def __init__(self, filepath, **kwargs):
           self.filepath = filepath
           super().__init__(**kwargs)
   
       def execute(self, context):
           self.log.info("https://example.com";)
           self.defer(
               trigger=FileTrigger(filepath=self.filepath),
               method_name="execute_complete",
           )
   
       def execute_complete(self, context, event=None):
           pass
   
   
   with DAG(
       dag_id="file_trigger",
       start_date=datetime(2021, 1, 1),
       catchup=False,
       schedule_interval=None,
   ) as dag:
       t1 = FileCheckOperator(task_id="t1", filepath="/tmp/a")
       t2 = FileCheckOperator(task_id="t2", filepath="/tmp/b")
   
       t1
       t2
   ```


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to