Fix schedule_tis HA race on try_number/state transitions#63367
Open
sidshas03 wants to merge 1 commit intoapache:mainfrom
Open
Fix schedule_tis HA race on try_number/state transitions#63367sidshas03 wants to merge 1 commit intoapache:mainfrom
sidshas03 wants to merge 1 commit intoapache:mainfrom
Conversation
4233546 to
add6ff0
Compare
add6ff0 to
590d384
Compare
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.
Related to #57618 and #60330.
This updates
DagRun.schedule_tis()to make scheduling more robust under HA scheduler races.TI.id IN (...)NULLorSCHEDULEABLE_STATES)next_try_numberexpression so behavior is consistent:UP_FOR_RESCHEDULEkeeps the sametry_numbertry_numberSUCCESS) to avoid stale scheduler views overwriting newer state.SCHEDULED(expected in race/no-op cases).In HA setups, two schedulers can race on the same TI. A stale scheduler view should not be able to:
try_numberagainQUEUED/RUNNING/ etc.This change makes those stale updates no-ops.
Tests added
In
airflow-core/tests/unit/models/test_dagrun.py:test_schedule_tis_does_not_increment_try_number_if_ti_already_queued_by_other_schedulertest_schedule_tis_empty_operator_does_not_short_circuit_if_ti_already_queuedtest_schedule_tis_up_for_reschedule_does_not_increment_try_numbertest_schedule_tis_is_noop_if_ti_transitions_to_nonschedulable_state_before_updatetest_schedule_tis_empty_operator_is_noop_if_ti_already_runningtest_schedule_tis_only_one_scheduler_update_succeeds_when_competingLocal validation
-k schedule_tissubset intest_dagrun.py: passed (existing expected xfails unchanged)