Skip to content

Restore accidentally removed variable assignment in the scheduler_job_runner - #61723

Merged
potiuk merged 1 commit into
apache:mainfrom
xBis7:dual-stats-manager-bug
Feb 10, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
xBis7:dual-stats-manager-bug

Conversation

@xBis7

@xBis7 xBis7 commented Feb 10, 2026 •

Copy link
Copy Markdown
Contributor

While running some manual tests with the metrics enabled, I noticed that the scheduler started exiting after triggering a few dags.

This is the stacktrace that I'm seeing in the logs

2026-02-10T10:21:07.655259Z [error    ] Exception when executing SchedulerJob._run_scheduler_loop
p [airflow.jobs.scheduler_job_runner.SchedulerJobRunner] loc=scheduler_job_runner.py:1324
Traceback (most recent call last):
  File "/opt/airflow/airflow-core/src/airflow/jobs/scheduler_job_runner.py", line 1319, in _execute
    self._run_scheduler_loop()
  File "/opt/airflow/airflow-core/src/airflow/jobs/scheduler_job_runner.py", line 1666, in _run_scheduler_loop
    next_event = timers.run(blocking=False)
  File "/usr/python/lib/python3.10/sched.py", line 151, in run
    action(*argument, **kwargs)
  File "/opt/airflow/airflow-core/src/airflow/utils/event_scheduler.py", line 40, in repeat
    action(*args, **kwargs)
  File "/opt/airflow/airflow-core/src/airflow/utils/session.py", line 100, in wrapper
    return func(*args, session=session, **kwargs)  # type: ignore[arg-type]
  File "/opt/airflow/airflow-core/src/airflow/jobs/scheduler_job_runner.py", line 2647, in _emit_ti_metrics
    extra_tags={"queue": queue, "dag_id": dag_id, "task_id": task_id},
UnboundLocalError: local variable 'queue' referenced before assignment
2026-02-10T10:21:07.699406Z [info     ] Shutting down LocalExecutor; waiting for running tasks t

This is actually my fault because in a previous PR of mine, #53722, I accidentally removed the variable assignment

This is the exact diff from the PR

-  dag_id, task_id, queue = prev_key
-  Stats.gauge(f"ti.{state}.{queue}.{dag_id}.{task_id}", 0)
-  Stats.gauge(f"ti.{state}", 0, tags={"queue": queue, "dag_id": dag_id, "task_id": task_id})
+  DualStatsManager.gauge(
+          f"ti.{state}",
+          0,
+          tags={},
+          extra_tags={"queue": queue, "dag_id": dag_id, "task_id": task_id},
+  )

This is the line that shouldn't have been removed

dag_id, task_id, queue = prev_key

I tested it manually and the error is gone.


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@potiuk
potiuk merged commit 4b4e66d into apache:main Feb 10, 2026
72 checks passed
@xBis7

xBis7 commented Feb 10, 2026

Copy link
Copy Markdown
Contributor Author

@shahar1 @potiuk Thank you!

@xBis7
xBis7 deleted the dual-stats-manager-bug branch February 10, 2026 12:12
Alok-kumar-priyadarshi pushed a commit to Alok-kumar-priyadarshi/airflow that referenced this pull request Feb 11, 2026
Ratasa143 pushed a commit to Ratasa143/airflow that referenced this pull request Feb 15, 2026
choo121600 pushed a commit to choo121600/airflow that referenced this pull request Feb 22, 2026
AkshayArali pushed a commit to AkshayArali/airflow_630 that referenced this pull request Feb 27, 2026
Subham-KRLX pushed a commit to Subham-KRLX/airflow that referenced this pull request Mar 4, 2026
dominikhei pushed a commit to dominikhei/airflow that referenced this pull request Mar 11, 2026
Ankurdeewan pushed a commit to Ankurdeewan/airflow that referenced this pull request Mar 15, 2026
radhwene pushed a commit to radhwene/airflow that referenced this pull request Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants