The GitHub Actions job "Tests" on airflow.git/fix-ha-scheduler-race has failed.
Run started by GitHub user ephraimbuddy (triggered by ephraimbuddy).

Head commit for run:
3ad9273e7bddd863c933fc56f7212ff300691b78 / Ephraim Anierobi 
<[email protected]>
Fix HA scheduler try_number double increment

In HA, two scheduler processes can race to schedule the same
TaskInstance. Previously DagRun.schedule_tis() updated rows by ti.id
alone, so a scheduler could increment try_number and transition
state even after another scheduler had already advanced the TI (e.g. to
SCHEDULED/QUEUED), resulting in duplicate attempts being queued.

This change makes scheduling idempotent under HA races by:
- Guarding schedule_tis() DB updates to only apply when the TI is still
in schedulable states (derived from SCHEDULEABLE_STATES, handling
NULL explicitly).

- Using a single CASE (next_try_number) so reschedules
(UP_FOR_RESCHEDULE) do not start a new try, and applying this
consistently to both normal scheduling and the EmptyOperator fast-path.

Adds regression tests covering:
- TI already queued by another scheduler.
- EmptyOperator fast-path blocked when TI is already QUEUED/RUNNING.
- UP_FOR_RESCHEDULE scheduling keeps try_number unchanged.
- Only one “scheduler” update succeeds when competing.

Report URL: https://github.com/apache/airflow/actions/runs/20854795094

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to