Uh oh!
There was an error while loading. Please reload this page.
Return 410 for stale id in set rtif API - #68902
Conversation
77810b5 to
c81b4a7Compare
SameerMesiah97
left a comment
There was a problem hiding this comment.
Looks good. Just one nit.
Uh oh!
There was an error while loading. Please reload this page.
jason810496
left a comment
There was a problem hiding this comment.
Nice! LGTM overall, thanks.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
When a task whose operator sets overwrite_rtif_after_execution=True leaves RUNNING via a retry or a clear, the server regenerates the task instance id and archives the old one. finalize() still overwrites RTIF with the stale id, so the API server returns 404 and the worker logs a spurious error traceback on top of the task's real outcome. The RTIF will be wrote in next id. Signed-off-by: PoAn Yang <payang@apache.org>
jason810496
left a comment
There was a problem hiding this comment.
Hi @FrankYang0529,
Would you mind to test the minimal reproduction mentioned in #66416 when you have a moment? Thanks.
@jason810496 Thanks for the review. I tested with following dag and we don't have error message in the first try from __future__ importannotationsimportdatetimefromairflow.sdkimportDAGfromairflow.sdk.bases.operatorimportBaseOperatorclassFailingOverwriteRTIFOperator(BaseOperator):
template_fields= ("message",)
overwrite_rtif_after_execution=Truedef__init__(self, *, message: str="hello {{ ds }}", **kwargs):
super().__init__(**kwargs)
self.message=messagedefexecute(self, context):
raiseRuntimeError("Intentional failure to reproduce RTIF finalize bug")
withDAG(
dag_id="repro_rtif_finalize",
start_date=datetime.datetime(2024, 1, 1),
schedule=None,
catchup=False,
):
FailingOverwriteRTIFOperator(
task_id="boom",
retries=1,
retry_delay=datetime.timedelta(seconds=5),
)![]() |
There was a problem hiding this comment.
Nice!
def__init__(self, *, message: str="hello {{ ds }}", **kwargs):
Hope you haven't terminated the cluster yet. Could we test with def __init__(self, *, message: str = "hello {{ ti.try_number }}", **kwargs): when you have a moment to double check are we able to get the Intentional failure to reproduce RTIF finalize bug sentinel error or not, thanks.
FrankYang0529
commented
Jul 7, 2026
jason810496
commented
Jul 7, 2026
Thanks! |
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.
|
When a task whose operator sets overwrite_rtif_after_execution=True leaves RUNNING via a retry or a clear, the server regenerates the task instance id and archives the old one. finalize() still overwrites RTIF with the stale id, so the API server returns 404 and the worker logs a spurious error traceback on top of the task's real outcome. The RTIF will be wrote in next id. (cherry picked from commit a327dd4) Co-authored-by: PoAn Yang <payang@apache.org> Signed-off-by: PoAn Yang <payang@apache.org>
When a task whose operator sets overwrite_rtif_after_execution=True leaves RUNNING via a retry or a clear, the server regenerates the task instance id and archives the old one. finalize() still overwrites RTIF with the stale id, so the API server returns 404 and the worker logs a spurious error traceback on top of the task's real outcome. The RTIF will be wrote in next id. (cherry picked from commit a327dd4) Co-authored-by: PoAn Yang <payang@apache.org> Signed-off-by: PoAn Yang <payang@apache.org>
When a task whose operator sets overwrite_rtif_after_execution=True leaves RUNNING via a retry or a clear, the server regenerates the task instance id and archives the old one. finalize() still overwrites RTIF with the stale id, so the API server returns 404 and the worker logs a spurious error traceback on top of the task's real outcome. The RTIF will be wrote in next id. (cherry picked from commit a327dd4) Co-authored-by: PoAn Yang <payang@apache.org> Signed-off-by: PoAn Yang <payang@apache.org>
When a task whose operator sets overwrite_rtif_after_execution=True leaves RUNNING via a retry or a clear, the server regenerates the task instance id and archives the old one. finalize() still overwrites RTIF with the stale id, so the API server returns 404 and the worker logs a spurious error traceback on top of the task's real outcome. The RTIF will be wrote in next id. (cherry picked from commit a327dd4) Co-authored-by: PoAn Yang <payang@apache.org> Signed-off-by: PoAn Yang <payang@apache.org>


Why
A task whose operator sets
overwrite_rtif_after_execution=Truelogs a 404 error when setting rtif. The server regenerates the task instance id (archiving the old one to history) via a retry or a clear. However, the worker'sfinalize()still overwritesRTIF using the stale id.
How
When a TI id is missing from the live table but present in history,
PUT /task-instances/{id}/rtifnow returns410 Goneinstead of404. The hearbeat API also uses this mechanism. The supervisor treats that410as an expected, skippable outcome (debug log, no error). A genuine404still propagates as a real error.closes: #66416
Was generative AI tooling used to co-author this PR?
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.