melugoyal commented on code in PR #47126:
URL: https://github.com/apache/airflow/pull/47126#discussion_r1972476077
##########
airflow/api_fastapi/execution_api/routes/task_instances.py:
##########
@@ -151,14 +151,16 @@ def ti_run(
"previous_state": previous_state,
},
)
- log.info("Task with %s state started on %s ", previous_state,
ti_run_payload.hostname)
+ else:
+ log.info("Task with %s state started on %s ", previous_state,
ti_run_payload.hostname)
# Ensure there is no end date set.
query = query.values(
end_date=None,
hostname=ti_run_payload.hostname,
unixname=ti_run_payload.unixname,
pid=ti_run_payload.pid,
- state=State.RUNNING,
+ state=TaskInstanceState.RUNNING,
+ last_heartbeat_at=timezone.utcnow(),
Review Comment:
so we're setting last_heartbeat_at now on the transition to run? this should
fix the issue that https://github.com/apache/airflow/pull/46777 is attempting
to fix too
##########
airflow/api_fastapi/execution_api/routes/task_instances.py:
##########
@@ -129,9 +121,17 @@ def ti_run(
query = update(TI).where(TI.id == ti_id_str).values(data)
- # TODO: We will need to change this for other states like:
- # reschedule, retry, defer etc.
- if previous_state != State.QUEUED:
+ previous_state = ti.state
+
+ # If we are already running, but this is a duplicate request from the same
client return the same OK
+ # -- it's possible there was a network glitch and they never got the
response
+ if previous_state == TaskInstanceState.RUNNING and (ti["hostname"],
ti["unixname"], ti["pid"]) == (
+ ti_run_payload.hostname,
+ ti_run_payload.unixname,
+ ti_run_payload.pid,
+ ):
+ log.info("Duplicate start request received for from %s ",
ti_run_payload.hostname)
Review Comment:
```suggestion
log.info("Duplicate start request received from %s ",
ti_run_payload.hostname)
```
--
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]