uranusjr commented on a change in pull request #20062:
URL: https://github.com/apache/airflow/pull/20062#discussion_r764756302



##########
File path: airflow/models/taskinstance.py
##########
@@ -1200,7 +1200,8 @@ def check_and_change_state_before_execution(
             # Attempt 0 for the first attempt).
             # Set the task start date. In case it was re-scheduled use the 
initial
             # start date that is recorded in task_reschedule table
-            self.start_date = timezone.utcnow()
+            # If the task continues after being deferred (next_method is set), 
use the original start_date
+            self.start_date = self.start_date if self.next_method else 
timezone.utcnow()

Review comment:
       The scheduler calls `set_state()` to defer a task, so I was suggesting 
setting `start_date` to None when that happens (the scheduler would commit this 
to the database), so when the task instance was fetched after deferral, the 
database record would have `start_date` of None. But if you feel clearing 
`start_date` in the database is wrong (based on your comment above), the best 
approach would be what you have right now, plus a comment reminding future 
maintainers to keep an eye on this part of the code base when they change the 
semantic of `next_method`.




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