Skip to content

Conversation

@henry3260
Copy link
Contributor

@henry3260 henry3260 commented Jan 21, 2026

Why:

The test_execution test is flaky due to a race condition. When the worker raises the intended RuntimeError, it crashes, causing the LocalExecutor to immediately respawn a new worker to maintain parallelism.

This creates an infinite crash-and-respawn loop if the new worker picks up the failing task again. As a result, executor.end() hangs (times out) because it cannot successfully join the processes while new ones are constantly being spawned.

How:

I introduced a has_failed_once flag to ensure the worker raises the RuntimeError only once. Subsequent executions will return successfully. This prevents the infinite respawn loop, allowing the worker to shut down gracefully and executor.end() to finish without timing out.

closes: #45329

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

  • 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.

@boring-cyborg boring-cyborg bot added the area:Executors-core LocalExecutor & SequentialExecutor label Jan 21, 2026
@henry3260 henry3260 force-pushed the flaky-test-execution branch 2 times, most recently from acf4f73 to 227fdf7 Compare January 21, 2026 19:11
@henry3260 henry3260 changed the title trigger ci Fix flaky test_execution test Jan 21, 2026
@henry3260 henry3260 marked this pull request as ready for review January 21, 2026 19:38
@henry3260 henry3260 force-pushed the flaky-test-execution branch from 227fdf7 to 10aa040 Compare January 23, 2026 12:27
@potiuk potiuk merged commit c9b0438 into apache:main Jan 27, 2026
70 checks passed
shreyas-dev pushed a commit to shreyas-dev/airflow that referenced this pull request Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Executors-core LocalExecutor & SequentialExecutor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test TestLocalExecutor.test_execution(unlimited) sometimes fail

2 participants