Repository navigation
Prevent a broken job from stalling AWS Batch executor sync - #71380
Merged
o-nikolas merged 3 commits intoAug 17, 2026
Merged
Conversation
A deterministic per-job error in sync_running_jobs() aborts every heartbeat before attempt_submit_jobs(), halting all task submission until the scheduler is restarted. Seen in production: a job whose bookkeeping was partially cleaned made pop_by_id() raise KeyError forever, wedging the whole executor.
|
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
|
vincbeck
approved these changes
Aug 10, 2026
vincbeck
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me but @o-nikolas' opinion on this one would be great
o-nikolas
reviewed
Aug 11, 2026
…nc error If the error strikes after pop_by_id() has already removed the job from the collection (for example success() itself raising), the collection can no longer resolve the workload key and the workload would linger with no terminal state. Snapshot the key before handling each job and use it as a fallback during eviction.
… sync handling Per review: credential problems are executor-wide, not job-specific, so they must keep reaching sync()'s connection handling even if future code inside the per-job block calls boto, instead of evicting the job they happened to surface on.
Contributor
|
Ran tests again, let's see if they go green |
Contributor
Author
@o-nikolas the re-run came back green and all checks passed. Anything else you'd like me to address here? Thanks! |
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
18 of 91 tasks
1 task done
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.
sync_running_jobs()handles all active jobs in a single pass, andsync()wraps the whole heartbeat in one catch-all. When handling of a single job raises, the exception aborts the entire cycle: the remaining jobs are not synced and, more importantly,attempt_submit_jobs()never runs. If the error is deterministic for that job, the executor stops submitting tasks entirely until the scheduler is restarted.This is not hypothetical.
BatchJobCollection.pop_by_id()raisesKeyErrorbefore cleaning anything when the collection's bookkeeping is partially cleaned (e.g. a duplicate submission for the same workload key overwriteskey_to_id, orphaning the older job id), so the failing job stays inactive_workersforever and every subsequent heartbeat aborts at the same job. We hit exactly this in production (Airflow 3.2.1,apache-airflow-providers-amazon==9.31.0): one poisoned workload halted all Batch submissions cluster-wide (~20 Dags piling up in queued) until a scheduler restart, the only signal beingFailed to sync AwsBatchExecutorrepeating every heartbeat.The fix:
sync_running_jobs()is handled in its owntry/except; an unexpected per-job error evicts that job and fails its workload instead of aborting the cycle;BatchJobCollection.remove_job()used for the eviction — a defensive removal that tolerates partially cleaned state, unlikepop_by_id().Credential-type boto errors (
ClientError/NoCredentialsError) still reachsync()'s handler unchanged: they can only be raised by_describe_jobs()/attempt_submit_jobs(), which sit outside the per-job block — nothing inside the block calls AWS.Tests: two
BatchJobCollection.remove_job()tests, eviction-with-isolation test (poisoned job evicted + failed, healthy job in the same cycle still succeeds), eviction survival whenfail()itself raises, and a regression test for the production impact (attempt_submit_jobs()still runs when a tracked job cannot be synced).Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Fable 5) following the guidelines
{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.