airflow icon indicating copy to clipboard operation
airflow copied to clipboard

Metric scheduler.tasks.running is never updated from 0

Open easontm opened this issue 3 years ago • 5 comments

Apache Airflow version

2.2.3 (latest released)

What happened

The metric scheduler.tasks.running is populated from the variable num_tasks_in_executor in scheduler_job.py. However, num_tasks_in_executor is initialized to 0 and then never updated again.

Function _executable_task_instances_to_queued: https://github.com/apache/airflow/blob/c59001d79facf7e472e0581ac8a538c25eebfda7/airflow/jobs/scheduler_job.py#L328

https://github.com/apache/airflow/blob/c59001d79facf7e472e0581ac8a538c25eebfda7/airflow/jobs/scheduler_job.py#L457

I considered just opening a PR modifying that value with the rest of these "counter" modifications: https://github.com/apache/airflow/blob/c59001d79facf7e472e0581ac8a538c25eebfda7/airflow/jobs/scheduler_job.py#L449-L452

However, I'm not sure if this is the best course of action because we don't know if the tasks is successfully added until the the list of executable TIs is returned within _critical_section_execute_task_instances, and those TIs are attempted to be queued in _enqueue_task_instances_with_queued_state.

https://github.com/apache/airflow/blob/c59001d79facf7e472e0581ac8a538c25eebfda7/airflow/jobs/scheduler_job.py#L534-L540

https://github.com/apache/airflow/blob/c59001d79facf7e472e0581ac8a538c25eebfda7/airflow/executors/base_executor.py#L73-L85

What you expected to happen

No response

How to reproduce

No response

Operating System

Ubuntu 19.10

Versions of Apache Airflow Providers

No response

Deployment

Other Docker-based deployment

Deployment details

No response

Anything else

No response

Are you willing to submit PR?

  • [ ] Yes I am willing to submit a PR!

Code of Conduct

easontm avatar Jan 17 '22 03:01 easontm

Yeah. Confirmed it does look suspiciously 0-always metrics :), Would you maube like to attempt to fix that one @easontm ?

potiuk avatar Feb 01 '22 14:02 potiuk

Opening PR and discussing there, might be the best way to get to the right solution as it will drag attention of those who are closer to the code.

potiuk avatar Feb 01 '22 14:02 potiuk

I won't be able to do it right away because of other obligations, but I'll see what I can do in a few weeks!

easontm avatar Feb 02 '22 02:02 easontm

Hi @potiuk, @easontm, do you mind if I take over?

ihorlukianov avatar Sep 19 '22 17:09 ihorlukianov

Feel free.

potiuk avatar Sep 19 '22 18:09 potiuk

I believe we could close this out as we removed that metrics https://github.com/apache/airflow/pull/30374. You should be using executor running and executor queued task metrics. cc: @vincbeck

shubham22 avatar Aug 17 '23 21:08 shubham22

Correct!

vincbeck avatar Aug 17 '23 21:08 vincbeck