Archive worker-reported end date and rendered map index on task retry - #69248
Merged
jason810496 merged 4 commits intoJul 6, 2026
Merged
Conversation
Follow-up to apache#69235. The task_instance_history row for a retried try stamped archive-time utcnow() as end_date instead of the end date the worker reported, and missed the final rendered map index when the mid-run update was suppressed (e.g. template errors during failure handling). Snapshot both onto the TI before archiving, and let record_ti() respect a pre-set end_date so the audit trail reflects when the try actually ended.
jason810496
requested review from
XD-DENG,
amoghrajesh,
ashb and
kaxil
as code owners
July 2, 2026 10:56
phanikumv
reviewed
Jul 3, 2026
Cover the conditional branch where record_ti() archives a non-finished TI with end_date=None, verifying it gets stamped with utcnow() and duration is computed correctly.
phanikumv
reviewed
Jul 6, 2026
phanikumv
approved these changes
Jul 6, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the fidelity of task_instance_history snapshots for retry transitions coming from the Execution API, ensuring the archived “finished try” reflects worker-reported values instead of archive-time defaults.
Changes:
- Update
TaskInstanceHistory.record_ti()to only stampend_date/durationwhenend_dateis unset, allowing callers (e.g. Execution API) to preserve worker-reported end times. - In the Execution API retry handler, populate the in-memory
TaskInstancewith retry-related fields (and timing/map-index fields) before archiving, so TIH captures them. - Extend/adjust regression tests to assert end-date/duration and
rendered_map_indexare archived as expected.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| airflow-core/tests/unit/models/test_taskinstance.py | Adds a unit test covering record_ti() end_date/duration stamping behavior. |
| airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py | Extends retry-history regression test to assert end_date, duration, and rendered_map_index. |
| airflow-core/src/airflow/models/taskinstancehistory.py | Changes record_ti() to avoid overwriting worker-provided end_date/duration when present. |
| airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py | Sets retry snapshot fields on the in-memory TI before archiving; consolidates retry_reason truncation. |
jason810496
marked this pull request as draft
July 6, 2026 08:27
jason810496
marked this pull request as ready for review
July 6, 2026 08:44
Contributor
Backport successfully created: v3-3-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
github-actions Bot
pushed a commit
to aws-mwaa/upstream-to-airflow
that referenced
this pull request
Jul 6, 2026
…n task retry (apache#69248) * Archive worker-reported end date and rendered map index on task retry Follow-up to apache#69235. The task_instance_history row for a retried try stamped archive-time utcnow() as end_date instead of the end date the worker reported, and missed the final rendered map index when the mid-run update was suppressed (e.g. template errors during failure handling). Snapshot both onto the TI before archiving, and let record_ti() respect a pre-set end_date so the audit trail reflects when the try actually ended. * Add test for record_ti fallback end_date stamping Cover the conditional branch where record_ti() archives a non-finished TI with end_date=None, verifying it gets stamped with utcnow() and duration is computed correctly. * Clarify record_ti comment covers pre-set duration too * Snapshot rendered_map_index in TIH when a retry explicitly clears it (cherry picked from commit 66b803d) Co-authored-by: Jason(Zhe-You) Liu <68415893+jason810496@users.noreply.github.com>
aws-airflow-bot
pushed a commit
to aws-mwaa/upstream-to-airflow
that referenced
this pull request
Jul 6, 2026
…n task retry (apache#69248) * Archive worker-reported end date and rendered map index on task retry Follow-up to apache#69235. The task_instance_history row for a retried try stamped archive-time utcnow() as end_date instead of the end date the worker reported, and missed the final rendered map index when the mid-run update was suppressed (e.g. template errors during failure handling). Snapshot both onto the TI before archiving, and let record_ti() respect a pre-set end_date so the audit trail reflects when the try actually ended. * Add test for record_ti fallback end_date stamping Cover the conditional branch where record_ti() archives a non-finished TI with end_date=None, verifying it gets stamped with utcnow() and duration is computed correctly. * Clarify record_ti comment covers pre-set duration too * Snapshot rendered_map_index in TIH when a retry explicitly clears it (cherry picked from commit 66b803d) Co-authored-by: Jason(Zhe-You) Liu <68415893+jason810496@users.noreply.github.com>
henry3260
pushed a commit
that referenced
this pull request
Jul 6, 2026
…n task retry (#69248) (#69458) * Archive worker-reported end date and rendered map index on task retry Follow-up to #69235. The task_instance_history row for a retried try stamped archive-time utcnow() as end_date instead of the end date the worker reported, and missed the final rendered map index when the mid-run update was suppressed (e.g. template errors during failure handling). Snapshot both onto the TI before archiving, and let record_ti() respect a pre-set end_date so the audit trail reflects when the try actually ended. * Add test for record_ti fallback end_date stamping Cover the conditional branch where record_ti() archives a non-finished TI with end_date=None, verifying it gets stamped with utcnow() and duration is computed correctly. * Clarify record_ti comment covers pre-set duration too * Snapshot rendered_map_index in TIH when a retry explicitly clears it (cherry picked from commit 66b803d) Co-authored-by: Jason(Zhe-You) Liu <68415893+jason810496@users.noreply.github.com>
vatsrahul1001
pushed a commit
that referenced
this pull request
Jul 7, 2026
…n task retry (#69248) (#69458) * Archive worker-reported end date and rendered map index on task retry Follow-up to #69235. The task_instance_history row for a retried try stamped archive-time utcnow() as end_date instead of the end date the worker reported, and missed the final rendered map index when the mid-run update was suppressed (e.g. template errors during failure handling). Snapshot both onto the TI before archiving, and let record_ti() respect a pre-set end_date so the audit trail reflects when the try actually ended. * Add test for record_ti fallback end_date stamping Cover the conditional branch where record_ti() archives a non-finished TI with end_date=None, verifying it gets stamped with utcnow() and duration is computed correctly. * Clarify record_ti comment covers pre-set duration too * Snapshot rendered_map_index in TIH when a retry explicitly clears it (cherry picked from commit 66b803d) Co-authored-by: Jason(Zhe-You) Liu <68415893+jason810496@users.noreply.github.com>
vatsrahul1001
pushed a commit
that referenced
this pull request
Jul 9, 2026
…n task retry (#69248) (#69458) * Archive worker-reported end date and rendered map index on task retry Follow-up to #69235. The task_instance_history row for a retried try stamped archive-time utcnow() as end_date instead of the end date the worker reported, and missed the final rendered map index when the mid-run update was suppressed (e.g. template errors during failure handling). Snapshot both onto the TI before archiving, and let record_ti() respect a pre-set end_date so the audit trail reflects when the try actually ended. * Add test for record_ti fallback end_date stamping Cover the conditional branch where record_ti() archives a non-finished TI with end_date=None, verifying it gets stamped with utcnow() and duration is computed correctly. * Clarify record_ti comment covers pre-set duration too * Snapshot rendered_map_index in TIH when a retry explicitly clears it (cherry picked from commit 66b803d) Co-authored-by: Jason(Zhe-You) Liu <68415893+jason810496@users.noreply.github.com>
vatsrahul1001
pushed a commit
that referenced
this pull request
Aug 5, 2026
…n task retry (#69248) (#69458) * Archive worker-reported end date and rendered map index on task retry Follow-up to #69235. The task_instance_history row for a retried try stamped archive-time utcnow() as end_date instead of the end date the worker reported, and missed the final rendered map index when the mid-run update was suppressed (e.g. template errors during failure handling). Snapshot both onto the TI before archiving, and let record_ti() respect a pre-set end_date so the audit trail reflects when the try actually ended. * Add test for record_ti fallback end_date stamping Cover the conditional branch where record_ti() archives a non-finished TI with end_date=None, verifying it gets stamped with utcnow() and duration is computed correctly. * Clarify record_ti comment covers pre-set duration too * Snapshot rendered_map_index in TIH when a retry explicitly clears it (cherry picked from commit 66b803d) Co-authored-by: Jason(Zhe-You) Liu <68415893+jason810496@users.noreply.github.com>
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.
What
ti_patch_payload.retry_reason[:500] if ti_patch_payload.retry_reason else Nonestatement.task_instance_history.end_date, it didn't respect theend_datepassed from worker (Execution API).rendered_map_indexcarried in the retry payload should also be snapshotted to the TIH table.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Fable 5) following the guidelines