Skip to content

fix(scheduler): ignore stale executor success after defer reschedule#66431

Open
Pedrinhonitz wants to merge 4 commits intoapache:mainfrom
Pedrinhonitz:fix-66374-defer-scheduled-stale-executor-success
Open

fix(scheduler): ignore stale executor success after defer reschedule#66431
Pedrinhonitz wants to merge 4 commits intoapache:mainfrom
Pedrinhonitz:fix-66374-defer-scheduled-stale-executor-success

Conversation

@Pedrinhonitz
Copy link
Copy Markdown

Summary

Fixes a race where the trigger resumes a deferred task to scheduled before the scheduler processes the executor SUCCESS from the worker defer exit. The scheduler then treated scheduled vs executor success as a state mismatch and failed the TI (#66374).

Changes

  • In process_executor_events, treat executor SUCCESS while the TI is SCHEDULED with next_method set (same try) as a stale defer-exit event, consistent with the existing “requeued after defer” intent.
  • Add test_process_executor_events_stale_success_when_scheduled_after_defer (positive + negative without next_method).
  • Add newsfragment 66374.bugfix.rst.

Testing

pytest airflow-core/tests/unit/jobs/test_scheduler_job.py::TestSchedulerJob::test_process_executor_events_stale_success_when_scheduled_after_defer -q

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

Generated-by: Cursor following the guidelines


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

When a trigger moves a deferred task back to scheduled before the
scheduler processes the executor success from the worker defer exit,
treat it as benign (same try_number, next_method set) instead of
state mismatch failure.

Closes apache#66374

Co-authored-by: Cursor <cursoragent@cursor.com>
@Pedrinhonitz Pedrinhonitz requested review from XD-DENG and ashb as code owners May 5, 2026 17:20
@boring-cyborg boring-cyborg Bot added the area:Scheduler including HA (high availability) scheduler label May 5, 2026
@boring-cyborg
Copy link
Copy Markdown

boring-cyborg Bot commented May 5, 2026

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

Comment thread airflow-core/newsfragments/66374.bugfix.rst Outdated
@Pedrinhonitz Pedrinhonitz requested a review from jscheffl May 5, 2026 17:46
Copy link
Copy Markdown
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for me. Thanks for the fix!

As I am not 100% deep in the scheduler feel not comfortable to mege, so if there is a second pair of eyes from reviewer would be cool, else LGTM!

@Pedrinhonitz
Copy link
Copy Markdown
Author

Perfect!

I'm also eagerly awaiting another review and am open to other suggestions for resolving this issue.

Thank you for your review.

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.

Race condition between scheduler processing events and trigger completion

2 participants