ephraimbuddy commented on code in PR #70990:
URL: https://github.com/apache/airflow/pull/70990#discussion_r3711680799
##########
airflow-core/src/airflow/dag_processing/processor.py:
##########
@@ -328,24 +328,31 @@ def _execute_callbacks(
dagbag: DagBag, callback_requests: list[CallbackRequest], log:
FilteringBoundLogger
) -> None:
for request in callback_requests:
+ request_json = request.to_json()
if isinstance(request, (TaskCallbackRequest, EmailRequest)):
log.debug(
"Processing Callback Request",
- request=request.to_json(),
+ request=request_json,
ti_id=str(request.ti.id),
)
else:
- log.debug("Processing Callback Request", request=request.to_json())
- with BundleVersionLock(
- bundle_name=request.bundle_name,
- bundle_version=request.bundle_version,
- ):
- if isinstance(request, TaskCallbackRequest):
- _execute_task_callbacks(dagbag, request, log)
- elif isinstance(request, DagCallbackRequest):
- _execute_dag_callbacks(dagbag, request, log)
- elif isinstance(request, EmailRequest):
- _execute_email_callbacks(dagbag, request, log)
+ log.debug("Processing Callback Request", request=request_json)
+ # A failed request (e.g. the Dag or task was removed since the callback
+ # was scheduled) must not abort the remaining requests in this batch --
+ # they were already popped from the manager's queue and would be lost.
+ try:
+ with BundleVersionLock(
+ bundle_name=request.bundle_name,
+ bundle_version=request.bundle_version,
+ ):
+ if isinstance(request, TaskCallbackRequest):
+ _execute_task_callbacks(dagbag, request, log)
+ elif isinstance(request, DagCallbackRequest):
+ _execute_dag_callbacks(dagbag, request, log)
+ elif isinstance(request, EmailRequest):
+ _execute_email_callbacks(dagbag, request, log)
+ except Exception:
+ log.exception("Failed to execute callback request",
request=request_json)
Review Comment:
Took the log and context changes; I left the counter out of this PR since a
request dying before its callback ran was equally invisible before this change,
so it's a pre-existing observability gap and not one this PR introduces. If we
add it, I think it belongs in a minor release as a new metric; happy to do that
in a follow-up if you still want it.
--
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]