tirkarthi commented on code in PR #38984:
URL: https://github.com/apache/airflow/pull/38984#discussion_r1564470882


##########
airflow/models/taskinstance.py:
##########
@@ -274,6 +274,12 @@ def clear_task_instances(
                 ti.state = TaskInstanceState.RESTARTING
                 job_ids.append(ti.job_id)
         else:
+            # When the task is deferred the try_number is decremented so that 
the same try
+            # number is used when the task resumes execution to process the  
event. But in case of
+            # clearing the try number should be incremented so that the next 
run doesn't reuse the same try_number
+            if ti.state == TaskInstanceState.DEFERRED:

Review Comment:
   @dirrao Sorry, I don't understand your comment. When the task moves from 
running to deferred the try number is decremented so that when task resumes 
from the trigger to running the try number is incremented so that same try 
number is used and helps with logging etc. When the task is cleared then the 
try number is incremented but since it's in deferred state with try number 
decremented it causes issues where same log file is used, retry count mismatch 
etc. for different attempts.



-- 
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