Repository navigation
Apply the configured XCom backend to language SDK task XComs - #75184
jason810496 merged 6 commits into
Conversation
5fa6540 to
e77b09a
Compare
462f4c9 to
848611a
Compare
|
Having a whole separate process to handle xcom uplodads feels overkill. Why can't we do it from the coordinator process directly? The "why" in the PR desc doesn't address this |
Good point, I've added this to the Why in the description:
The helper is also lazy and per task: it starts on the first call the configured backend handles and serves all of that task's XCom calls, so tasks on the default It is also not meant for XCom only. Any worker-side backend that runs in a Python task's process and keeps in-memory state should run in this helper for the same isolation, so the |
|
My 2 cents... I like the shape of keeping the backend out of the supervisor. But making this new XCom process a mini event loop (heartbeat, its own execution_timeout) feels kinda heavy... Is it possible to make the supervisor just hand the call to the helper and go back to its normal loop? Then the only thing the XCom process does is run the backend call itself, and we can still monitor the XCom helper process from the same selector we use for the task runner socket. The supervisor can also get the result by listening on the XCom helper's socket, and reply to the task runner once it's done. Maybe there's a reason this doesn't work -- curious what you ran into. |
848611a to
a0675cc
Compare
4c2fbf6 to
c5f8103
Compare
jason810496
left a comment
There was a problem hiding this comment.
Thanks for the review.
I just addressed all the comments and squad some of the commits.
shivaam
left a comment
There was a problem hiding this comment.
Two questions about API error reporting and startup cleanup.
Drafted-by: Codex (GPT-6) (no human review before posting)
c5f8103 to
2343a9b
Compare
|
Looks like there’s rebase accident. The squash commit |
jason810496
left a comment
There was a problem hiding this comment.
Thanks for the review.
2343a9b to
f9759b4
Compare
Fixed in 2d46e70, I didn't realize in the last round, thanks. |
f9759b4 to
2d46e70
Compare
shivaam
left a comment
There was a problem hiding this comment.
Looks good. Tested it as well.
jason810496
left a comment
There was a problem hiding this comment.
Thanks for the review.
TypeScript, Go and Java tasks sent their XComs to the API server without the configured XCom backend. They read the stored reference of a value that a Python task wrote, such as an S3 path, instead of the value, their own values stayed in the metadata database, and clearing a try left stored objects behind. The supervisor now runs the backend's store, load and purge on a runtime's XCom requests, in a helper process per task started like a Python task process, so the long-lived worker process keeps none of the backend's state. Every backend but the default one runs there. A backend failure fails the request, as it fails a Python task, and reaches the runtime as the new XCOM_BACKEND_ERROR. It is added in supervisor schema 2027-02-28, so a runtime pinned to an older version gets GENERIC_ERROR. The Java SDK moves to 2027-02-28 like Go and TypeScript, and the three SDK matrices declare a custom-xcom-backend capability.
No e2e test checked that TypeScript, Go and Java tasks store and read their XComs through the configured XCom backend. The new lang_sdk_xcom_object_storage mode runs one Dag definition in each language SDK with XComObjectStorageBackend on LocalStack, and checks the stored objects and the values the tasks read back. It has its own file group and run-lang-sdk-xcom-e2e-tests output, so a change to the XCom backend does not run the Java, Go and TypeScript SDK e2e jobs too.
The Java SDK declares supervisor schema 2027-02-28, which an Airflow 3.4 supervisor rejects.
A send now skips a process whose exit the supervisor has handled, and catches only BrokenPipeError and ConnectionResetError for one that died before that, as the supervisor does for a task process.
A rejected write of a stored reference reached the runtime as an XCom backend failure, pointing the user at their backend instead of the API server. Clearing the XComs of an earlier try runs before the loop that heartbeats, so a slow purge could let the running task's heartbeat lapse.
… stopped A runtime gets the same error for a rejected request whichever path made it. Clearing XComs no longer waits out a purge for a task that the server stopped or whose process has exited.
7a13d64 to
d540af6
Compare
jason810496
left a comment
There was a problem hiding this comment.
I just rebased again to resolve the conflict and checked there isn't any rebase corruption before enabling auto-merge.
Changes since the last review.
Why
Run the configured
[core] xcom_backendat the supervisor, so TypeScript, Go and Java tasks store, read and purge XComs through it like Python tasks.The backend runs in a helper process rather than in the supervisor itself:
XComObjectStorageBackendcaches, breaks Python tasks forked from it later (This class is not fork-safe).execution_timeoutor when the server stops the task.The helper starts on the first call the configured backend handles, so tasks on the default
BaseXComnever start it.How
SetXCom,GetXCom,GetXComSequenceItem,GetXComSequenceSlice,DeleteXCom) and on the XComs it clears when a try starts. With the defaultBaseXCom, requests go to the API server unchanged.[core] execute_tasks_new_python_interpreter). So the long-lived worker process keeps none of the backend's state, such as a cachedS3FileSystemthat a Python task forked from it later could not use.store_value, and a loaded value is encoded with serde again.skipmixin_keybypasses the backend for every task, since the scheduler reads it from the XCom row as it is. Operator extra-link keys (_link_*) bypass it for language SDK tasks only, so Python tasks keep the behaviour they have today.execution_timeout.XCOM_BACKEND_ERRORrather thanAPI_SERVER_ERROR, which would point a user at the API server instead of at their own backend.2027-02-28, so it requires Airflow 3.5.0, like the Go and TypeScript SDKs.lang_sdk_xcom_object_storagee2e mode runs a Dag definition in each of TypeScript, Go and Java withXComObjectStorageBackendon LocalStack.The backend needs no SDK change, since all three runtimes only talk to the supervisor. With this config, TypeScript, Go and Java tasks read and write offloaded XComs like Python tasks:
Lifecycle
sequenceDiagram participant Runtime as Runtime (TS, Go, Java) participant Supervisor participant Backend as XCom backend process participant API as API server participant Storage as Object storage Note over Supervisor,Backend: The XCom backend process starts on the first call the backend handles,<br/>by fork, or by exec on macOS or with execute_tasks_new_python_interpreter Supervisor->>API: get and delete the XComs of the earlier try Supervisor->>Backend: purge(row) Backend->>Storage: delete object Note over Supervisor,Backend: The supervisor heartbeats while it waits for purge, and stops waiting once the task is stopped.<br/>A purge that fails or takes over 60 seconds fails the try Runtime->>Supervisor: SetXCom(key, value) Supervisor->>Backend: store(coordinate, key, value) opt a Connection the backend's own secrets backends do not have Backend->>Supervisor: GetConnection Supervisor-->>Backend: Connection, read from the API server end Backend->>Storage: write value Backend-->>Supervisor: s3://... reference Supervisor->>API: set the XCom row to the reference Runtime->>Supervisor: GetXCom(task_id, key) Supervisor->>API: get the XCom row Supervisor->>Backend: load(row) Backend->>Storage: read value Backend-->>Supervisor: value Supervisor-->>Runtime: value Note over Supervisor,Backend: The supervisor answers the runtime once the call returns, and goes on heartbeating<br/>and enforcing execution_timeout while it runs Runtime->>Supervisor: exits Supervisor->>Backend: exitWas generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5.5) following the guidelines