dabla opened a new issue, #76377:
URL: https://github.com/apache/airflow/issues/76377
### Apache Airflow version
main (3.4.0rc2 behaves the same)
### What happened?
Clearing a DAG run's tasks with "run on latest version" when the cleared set
includes the task that produces a mapped task's input marks every instance of
the mapped task `removed`, and they stay `removed` after the producer has run
again. Downstream tasks then run as if the mapped task were done.
### What you think should happen instead?
The mapped instances are cleared like the others (state `None`) and are
expanded again once the producer has pushed its new value.
### How to reproduce
```python
with DAG("clear_latest_mapped", schedule=None):
size = EmptyOperator(task_id="size") # pushes the list the
mapped task expands over
MockOperator.partial(task_id="task").expand(arg1=size.output)
```
1. Run it: `size` succeeds with `[1, 2]`, `task` expands into map indexes 0
and 1, all succeed.
2. Change the Dag so a new version is serialized.
3. Clear all task instances of the run with "run on latest version"
(`clear_task_instances(..., run_on_latest_version=True)`).
Result: `size` is `None`, `task` 0 and 1 are `removed`. After `size`
succeeds again and the scheduler runs, `task` 0 and 1 are still `removed`.
### Where
- `clear_task_instances(run_on_latest_version=True)` calls
`DagRun.verify_integrity()`, which reaches
`_check_for_removed_or_restored_tasks`. For the mapped task
`get_parse_time_mapped_ti_count()` and then `get_mapped_ti_count()` raise
`NotFullyPopulated`, because the producer's new attempt has no XCom yet, and
the branch commented "Not all upstreams finished, so we can't tell what should
be here. Remove everything." sets every `map_index >= 0` to `REMOVED`.
- Nothing brings them back: `_revise_map_indexes_if_mapped` only runs for
schedulable instances, and `expand_mapped_task` starts from the `map_index=-1`
placeholder, which no longer exists.
- The scheduler's own path is not affected: `_revise_map_indexes_if_mapped`
returns early on `NotFullyPopulated`.
A possible direction: when the count cannot be resolved yet, leave the
existing map indexes cleared instead of removing them, and let
`_revise_map_indexes_if_mapped` trim or extend them once the producer has run.
### Are you willing to submit PR?
Yes
--
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]