Count post-deferral scheduled tasks toward include_deferred pool slots#69770
Open
cipheraxat wants to merge 1 commit into
Open
Count post-deferral scheduled tasks toward include_deferred pool slots#69770cipheraxat wants to merge 1 commit into
cipheraxat wants to merge 1 commit into
Conversation
When include_deferred is enabled, tasks that return to scheduled after a trigger fires (next_method set) kept dropping out of pool occupancy, undercounting slots until they were queued again. Count those TIs as occupied without treating first-lifetime scheduled tasks the same way, which would deadlock scheduling.
|
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
|
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.
Summary
When a pool has
include_deferred=True, deferred tasks correctly occupy slots, but after the trigger fires the task instance goesdeferred → scheduledand previously stopped counting until it was queued/running again. That undercounts pool usage and weakens pools as a semaphore around external resources (the motivation for including deferred tasks in the first place).This change counts post-deferral
scheduledtask instances — those withnext_methodset — toward pool occupancy wheninclude_deferredis enabled:Pool.occupied_slots()/Pool.slots_stats()open calculationPool.task_instance_occupies_slot()used byPoolSlotsAvailableDepso a TI that already holds a slot does not block itselfFirst-lifetime
scheduledtasks (nonext_method) are not counted, which would otherwise deadlock scheduling whenopen = total - scheduled.Test plan
test_open_slots_including_deferred_counts_post_deferral_scheduledtest_open_slots_excluding_deferred_ignores_post_deferral_scheduledtest_post_deferral_scheduled_pooled_task_pass(pool slots available dep)prekon changed filesWas generative AI tooling used to co-author this PR?
Generated-by: Cursor following the guidelines