jedcunningham opened a new pull request, #71696:
URL: https://github.com/apache/airflow/pull/71696

   A Dag run can have no version of its own: runs carried over from Airflow 2 
predate the version columns, and `airflow db clean` can remove the version a 
run was created with. The latest is then the only version such a run can use, 
but clearing left it without one, and a task instance with no version is never 
enqueued — so the task sat in `queued` until it timed out, while its revived 
run held up new ones.
   
   Clearing now moves such a run and its task instances to the latest version 
together. The clear dialogs also show the "run with latest bundle version" 
option for these runs, checked and disabled, since previously they only offered 
it when there was a version to compare against — leaving no workaround.
   
   ### Verified
   
   Reproduced end to end rather than simulated: real Airflow 2.11.2 against 
Postgres, 13 scheduled runs executed by the Airflow 2 scheduler, then a real 
`airflow db migrate` to Airflow 3. That leaves 
`dag_run.created_dag_version_id`, `dag_run.bundle_version` and 
`task_instance.dag_version_id` all NULL, which is the state this fixes.
   
   Before the fix, clearing a task on a migrated run:
   
   ```
   [warning] TaskInstance legacy_dag.second scheduled__2026-08-05... does not 
have a dag_version_id set, cannot be enqueued
   second | queued     <- never handed to the executor
   ```
   
   After, on the same database:
   
   ```
   second | success | dag_version_id=01a00205-... | try_number=2
   dag_run | success
   enqueue refusals: 0
   ```
   
   The `airflow db clean` route was confirmed the same way: a run whose task 
instances the scheduler had moved to a newer version, leaving the original 
referenced only by the run, has its version deleted and 
`created_dag_version_id` nulled.
   
   UI verified in a browser against that migrated database — the option renders 
checked and disabled on version-less runs (both the run and task instance 
dialogs) and is correctly absent on runs that have a version. Screenshots to 
follow.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (Opus 5)
   
   Generated-by: Claude Code (Opus 5) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to