gaxeliy commented on issue #64628:
URL: https://github.com/apache/airflow/issues/64628#issuecomment-7273592293
I'd like to pick this up, building on the analysis earlier in this thread.
If the earlier
commenter is actively working on it, I'm happy to coordinate or split the
work.
Both #64743 and #69508 were closed without a technical decision; the more
complete one
(#69508) passed triage and then had no reviewer. Their patches also no
longer apply as-is:
handler dispatch moved to `_register_client_handler`, and language SDK XComs
now go through a
helper process for non-default backends. I'm reusing the useful parts of
that work (deferred
reply, ordered replies, error mapping).
**Root cause.** `SetXCom` is handled inline in the supervisor's selector
loop, which also sends
the task heartbeat. While `handle_set_xcom` runs the POST, the loop does not
return to
`_monitor_subprocess`, so `_send_heartbeat_if_needed` is not called. A large
upload that keeps
making progress can exceed `task_instance_heartbeat_timeout` (300s default),
and the scheduler
fails the task. `[workers] execution_api_timeout` does not bound it: httpx2
timeouts are per
connect/read/write/pool operation, not per request.
**Proposal.** Defer only the API call, not the whole handler.
`handle_set_xcom(client, msg)`
runs on a short-lived daemon thread; the worker only makes the call, and the
loop thread sends
the reply, so at most one offloaded call is in flight per child. In
`_PopenActivitySubprocess`,
only the non-helper branch is deferred; the branch that starts the XCom
backend helper stays on
the loop. The helper itself will be started with `use_exec=True`
(posix_spawn), so a bare fork
cannot inherit an SSL lock or the supervisor's API sockets while the worker
thread exists. This
reuses the existing `ResponseSent.ALREADY_SENT` deferred-reply pattern
already used for the XCom
backend helper.
**Open questions.**
1. After the fix, the heartbeat timeout no longer bounds the push: a huge
upload can take
arbitrarily long, and if the API server stalls, the task can block
indefinitely. One option
is a configurable `[core] max_xcom_size` (0 = unlimited), checked before
the push and
enforced by the Execution API, failing with a clear error that points at
`xcom_objectstorage_threshold`. PostgreSQL jsonb cannot store a single
value above about
268 MB (#73248), so anything above that cannot be stored there. I'd ship
this as a separate
PR unless you prefer it here.
2. `GetXCom` blocks the same loop while a large value is downloaded and
written to the child,
and the language SDK path can involve the backend helper. I'd keep this
PR to `SetXCom` and
open a separate issue for `GetXCom`, unless you want both now.
--
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]