You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "myps6415 (via GitHub)" <gi...@apache.org> on 2026/10/01 02:25:20 UTC
Re: [PR] Fix missing task.queued_duration metric in Airflow 3 [airflow]
myps6415 commented on code in PR #67592:
URL: https://github.com/apache/airflow/pull/67592#discussion_r4151223385
##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py:
##########
@@ -244,6 +251,12 @@ def ti_run(
extra=json.dumps({"host_name": ti_run_payload.hostname}) if ti_run_payload.hostname else None,
)
)
+ # One sample per queue wait, not per try: the scheduler refreshes queued_dttm on every
+ # queueing, so a retry and a resume from deferral each waited for a slot of their own.
+ # task.scheduled_duration counts per try instead, so the two disagree on retries by design.
+ # queued_dttm is None only in rare races and test setups.
Review Comment:
Fair point — that wording came from Airflow 2's `emit_state_change_metric` ("tests or rare cases") and I don't have a concrete race either. `_reschedule_stuck_task` clears `queued_dttm` but sets the TI back to SCHEDULED, so the scheduler sets it again before the task runs; the real case is runs that skip the queue entirely, e.g. `dag.test()`. Keeping the guard as you suggest.
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org