ephraimbuddy commented on code in PR #76303:
URL: https://github.com/apache/airflow/pull/76303#discussion_r4667459814


##########
airflow-core/src/airflow/models/trigger.py:
##########
@@ -908,17 +908,19 @@ def _(event: BaseTaskEndEvent, *, task_instance: 
TaskInstance, session: Session)
     callback_type = event.task_instance_state
     should_retry = False
     dag_bag = DBDagBag()
+    dag = None
 
-    if event.task_instance_state == TaskInstanceState.FAILED:
-        # Load the serialized task so retry eligibility matches the normal 
task path.
+    if event.task_instance_state in (TaskInstanceState.SUCCESS, 
TaskInstanceState.FAILED):

Review Comment:
   Good catch. Only `FAILED` loads the serialized Dag now. I added a regression 
test that checks a success event skips the load and still preserves the run’s 
bundle version.
   



##########
task-sdk/src/airflow/sdk/api/client.py:
##########
@@ -1204,11 +1208,33 @@ def __init__(self, client: Client):
 
     def run(self, callback_id: uuid.UUID) -> None:
         """Exchange the single-use callback token for an execution token."""
-        self.client.patch(f"callbacks/{callback_id}/run")
+        # Retries of this request resend the same attempt ID, so the API 
server accepts a retry whose
+        # first response was lost, but not a second delivery of the callback.
+        body = CallbackRunPayload(hostname=get_hostname(), pid=os.getpid(), 
attempt_id=uuid.uuid4())
+        try:
+            self.client.patch(f"callbacks/{callback_id}/run", 
content=body.model_dump_json())
+        except ServerResponseError as e:
+            if e.response.status_code == HTTPStatus.CONFLICT:

Review Comment:
   The reaper now covers `RUNNING` deadline callbacks even with routing off. If 
the worker stops heartbeating, the scheduler marks the callback failed and 
releases its executor slot. I added coverage for both a lost worker and one 
that’s still heartbeating.
   



-- 
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