o-nikolas commented on code in PR #76303:
URL: https://github.com/apache/airflow/pull/76303#discussion_r4619575803


##########
providers/amazon/src/airflow/providers/amazon/aws/executors/aws_lambda/lambda_executor.py:
##########
@@ -73,6 +74,10 @@
         WorkloadKey: TypeAlias = TaskInstanceKey  # type: ignore[no-redef, 
misc]
 
 
+# Allow for Lambda's asynchronous retries before SQS's maximum 14-day message 
retention.
+_RELEASED_CALLBACK_RETENTION = 15 * 24 * 60 * 60

Review Comment:
   Nit: 15 days seems longer than this needs. Lambda drops an async event after 
at most 6 hours (`MaximumEventAgeInSeconds`) and a function runs at most 15 
minutes, and this map lives in memory, so a scheduler restart clears it anyway. 
Since `sync_running_workloads` now keeps polling SQS and the DLQ while anything 
is in `_released_callbacks`, one result that never arrives keeps an otherwise 
idle executor polling every heartbeat for two weeks. Something like 6h + 15m 
would cover Lambda's retries.



##########
task-sdk/src/airflow/sdk/execution_time/execute_workload.py:
##########
@@ -99,7 +102,11 @@ def main():
             log.error("Failed to parse input JSON string", error=str(e))
             sys.exit(1)
 
-    execute_workload(workload)
+    try:
+        execute_workload(workload)
+    except CallbackAlreadyStartedError:
+        # A container executor must distinguish a duplicate delivery from the 
admitted worker's failure.
+        sys.exit(os.EX_TEMPFAIL)

Review Comment:
   +1 from the provider side. The ECS, Batch and Lambda executors each match on 
`os.EX_TEMPFAIL` for callback keys (`ecs_executor.py` L408, `batch_executor.py` 
L358, `lambda_executor.py` L568), and they use `hasattr(BaseExecutor, 
"supports_routed_callbacks")` as the feature check in about ten places. One 
documented hook on `BaseExecutor` would let the providers replace most of that 
with a single version guard. If the flag goes away per your `base_executor.py` 
comment, the providers need a different marker anyway, so it'd be good to 
settle both together.



##########
providers/amazon/src/airflow/providers/amazon/aws/executors/ecs/ecs_executor.py:
##########
@@ -341,6 +349,23 @@ def sync(self):
             # up and kill the scheduler process
             self.log.exception("Failed to sync %s", self.__class__.__name__)
 
+    def release_callback(self, key: CallbackKey) -> None:

Review Comment:
   When the reaper replaces a callback that missed its start deadline, 
`release_callback` stops tracking it but leaves the ECS task in place (same for 
the Batch job in `batch_executor.py` L281). A task still PROVISIONING/PENDING 
on a busy cluster, or a Batch job sitting RUNNABLE while the compute 
environment scales up, will still start later, get a 409 from `/run`, and take 
capacity the replacement callback is waiting for. You already stop the task for 
the in-flight RunTask case, so should this also `stop_task` / `terminate_job` 
when the tracked task or job hasn't reached RUNNING yet? I'd leave RUNNING ones 
alone, since that's the normal path where the worker reported before ECS saw 
the task exit. Fine as a follow-up too, since tasks requeued after 
`task_queued_timeout` have the same gap today.



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