Repository navigation
Fix scheduler crash on restart with queued or running Edge tasks - #73832
Merged
shahar1 merged 2 commits intoOct 2, 2026
Merged
Conversation
FrankYang0529
force-pushed
the
airflow-edge3-adopt-scheduler-session
branch
2 times, most recently
from
October 2, 2026 05:43
92b108e to
ce51b71
Compare
FrankYang0529
marked this pull request as ready for review
October 2, 2026 11:53
FrankYang0529
requested review from
dheerajturaga,
jscheffl and
shubhamraj-git
as code owners
October 2, 2026 11:53
shahar1
approved these changes
Oct 2, 2026
1 task done
Contributor
|
I've accidentally ommitted this PR from #74097, I'm adding the changelog as part of this one. |
Signed-off-by: PoAn Yang <payang@apache.org>
shahar1
force-pushed
the
airflow-edge3-adopt-scheduler-session
branch
from
October 2, 2026 17:17
ce51b71 to
b407544
Compare
This was referenced Oct 2, 2026
shahar1
added a commit
to shahar1/airflow
that referenced
this pull request
Oct 3, 2026
A PR that only changes a provider runs that provider's tests, with its direct dependents, in a pytest process of its own. On canary, the same tests run inside the shared Providers[-amazon,celery,google,standard] process, after every provider that sorts before them. cncf.kubernetes tests reload airflow.executors.executor_loader and leave its state behind, so a test that mocks ExecutorLoader through the module path can pass in its PR and fail on every canary build and release-candidate check afterwards. PR apache#73832 did exactly that with an edge3 test. Selective checks now add the providers listed in PROVIDERS_WITH_PROCESS_GLOBAL_TEST_SIDE_EFFECTS to the Providers[...] test type whenever a provider whose own files changed sorts after them, so the PR runs those tests in the order canary does. Dependents pulled in only for coverage do not widen the selection, and the CI job description keeps naming the selected providers.
shahar1
added a commit
that referenced
this pull request
Oct 3, 2026
…74123) A PR that only changes a provider runs that provider's tests, with its direct dependents, in a pytest process of its own. On canary, the same tests run inside the shared Providers[-amazon,celery,google,standard] process, after every provider that sorts before them. cncf.kubernetes tests reload airflow.executors.executor_loader and leave its state behind, so a test that mocks ExecutorLoader through the module path can pass in its PR and fail on every canary build and release-candidate check afterwards. PR #73832 did exactly that with an edge3 test. Selective checks now add the providers listed in PROVIDERS_WITH_PROCESS_GLOBAL_TEST_SIDE_EFFECTS to the Providers[...] test type whenever a provider whose own files changed sorts after them, so the PR runs those tests in the order canary does. Dependents pulled in only for coverage do not widen the selection, and the CI job description keeps naming the selected providers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
@provide_sessiontoEdgeExecutor.try_adopt_task_instances()so that the method could read theedge_jobtable.adopt_or_reset_orphaned_tasks()without passing a session. At that point, the scheduler's session still holds the orphaned task instances, which the scheduler loaded withload_only(...).@provide_sessiondoes not open a new session in this case. It callscreate_session(), which returns the thread-scoped session. In the scheduler's thread, that is the session the scheduler is already using. Whentry_adopt_task_instances()returns,create_session()commits and closes the scheduler's session in the middle of the adoption.ti.last_heartbeat_aton a detached task instance and exits withDetachedInstanceError.How
edge_jobrows throughcreate_session(scoped=False), which opens a separate session and leaves the scheduler's session and the orphaned task instances alone.Verification
uv run --frozen --project providers/edge3 pytest providers/edge3/tests/unit/edge3/executors/test_edge_executor.pyThe first
airflow scheduler --num-runs 5queues three of the six tasks, because[core] parallelismis 3, and then exits. The second one is the restart. It should adopt the three task instances that the first scheduler left queued.On this branch, the restart adopts them. The adopted task instances keep their slots, so the scheduler logs
Executor parallelism limit reachedin each of its five loops and the other three tasks stay scheduled:On
main, the task states are the same, but the restart crashes before it adopts anything:Was generative AI tooling used to co-author this PR?
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.