kalluripradeep commented on issue #67521:
URL: https://github.com/apache/airflow/issues/67521#issuecomment-4766830232
Thanks for the review @kevinhongzl. I traced the full code path to explain
why reproduction is inconsistent, and where the definitive gap is.
## Why it is hard to reproduce in the common case
When `poke()` sets `context["map_index_template"]` and raises
`AirflowRescheduleException`, the inner `except Exception:` block in
`task_runner.run()` (line 1576) **does** call `_render_map_index()` and sends
`SetRenderedMapIndex` to the supervisor **before** `RescheduleTask` is sent
(line 1627). Because the subsequent `UP_FOR_RESCHEDULE` route handler only
writes `state / next_method / next_kwargs` and leaves `_rendered_map_index`
untouched, the value set by `SetRenderedMapIndex` survives. So in the happy
path the label appears correctly — which is likely why you could not reproduce
it.
## Where the code gap is definitively broken
**Startup reschedule path** (`task_runner.py`, lines 2314-2320):
```python
except AirflowRescheduleException as reschedule:
SUPERVISOR_COMMS.send(
msg=RescheduleTask(
reschedule_date=reschedule.reschedule_date,
end_date=datetime.now(tz=timezone.utc),
# rendered_map_index is absent here
)
)
```
Here `AirflowRescheduleException` is raised inside `startup()`, **before**
`_prepare()` runs and before any `SetRenderedMapIndex` can be sent.
`RescheduleTask` goes out with no `rendered_map_index`, leaving
`_rendered_map_index` NULL in the DB for that reschedule row. This path is
exercised when a sensor rescheduled on the very first poke without entering the
main `run()` loop.
**Model-level inconsistency** (the underlying defect):
Every other intermediate-state payload carries `rendered_map_index` —
`TIDeferredStatePayload`, `TIAwaitingInputStatePayload`, `TIRetryStatePayload`,
`TITerminalStatePayload`, `TISuccessStatePayload` — but
`TIRescheduleStatePayload` does not. The route handler for `UP_FOR_RESCHEDULE`
therefore can never write the field explicitly; it depends entirely on a prior
`SetRenderedMapIndex` call, which the startup path never sends.
## Fix
PR #68829 adds `rendered_map_index` to `TIRescheduleStatePayload` and
threads it through `task_runner → supervisor → route handler → DB`, exactly
matching the pattern used by every other state payload. It also covers the
startup-reschedule path that `SetRenderedMapIndex` cannot reach.
--
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]