Skip to content

Refactor scheduler task concurrency evaluation into a dedicated helper.#67589

Draft
SameerMesiah97 wants to merge 1 commit into
apache:mainfrom
SameerMesiah97:SchedulerJobRunner-Concurrency-Helper
Draft

Refactor scheduler task concurrency evaluation into a dedicated helper.#67589
SameerMesiah97 wants to merge 1 commit into
apache:mainfrom
SameerMesiah97:SchedulerJobRunner-Concurrency-Helper

Conversation

@SameerMesiah97
Copy link
Copy Markdown
Contributor

Description

This change refactors task concurrency evaluation logic out of SchedulerJobRunner._executable_task_instances_to_queued into a dedicated helper method.

Task concurrency checks for max_active_tis_per_dag and max_active_tis_per_dagrun, along with their associated serialized DAG loading, starvation bookkeeping, and missing DAG handling, were previously implemented inline inside the main scheduling loop. This logic has now been extracted into _task_concurrency_allows_execution.

The new helper encapsulates serialized DAG retrieval and missing DAG handling, task-level and task-per-DAG-run concurrency checks, and concurrency starvation bookkeeping and logging.

Rationale

_executable_task_instances_to_queued currently performs a large number of responsibilities, including pool management, DAG-level concurrency enforcement, task-level concurrency evaluation, executor routing, starvation tracking, and queue state transitions.

The task concurrency section in particular introduced deeply nested control flow and intermixed concurrency-specific behavior directly inside the main scheduling loop, making the scheduling path harder to visually scan and maintain.

Tests

No test adjustments were required because this change is a refactor only and does not introduce any behavioral changes.

Backwards Compatibility

This change is a refactor only and does not modify scheduler behavior, public APIs, task concurrency semantics, or executor interactions.

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: [GPT 5.5] following the guidelines

Move serialized DAG retrieval, concurrency checks, and starvation
bookkeeping out of _executable_task_instances_to_queued.
@boring-cyborg boring-cyborg Bot added the area:Scheduler including HA (high availability) scheduler label May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Scheduler including HA (high availability) scheduler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant