Skip to content

Apply the configured XCom backend to language SDK task XComs - #75184

Merged
jason810496 merged 6 commits into
apache:mainfrom
jason810496:feature/lang-sdk/xcom-backend-in-coordinator
Nov 12, 2026
Merged

jason810496 merged 6 commits into
apache:mainfrom
jason810496:feature/lang-sdk/xcom-backend-in-coordinator

Conversation

@jason810496

@jason810496 jason810496 commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Changes since the last review.

Why

Run the configured [core] xcom_backend at 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:

  • The supervisor runs in the long-lived worker process, which also forks Python task processes. Backend state left there, such as the fsspec filesystem that XComObjectStorageBackend caches, breaks Python tasks forked from it later (This class is not fork-safe).
  • A backend call blocks on I/O. With the call in another process, the supervisor keeps heartbeating and can stop it on execution_timeout or when the server stops the task.

The helper starts on the first call the configured backend handles, so tasks on the default BaseXCom never start it.

How

  • The supervisor of a language SDK task runs the backend on the runtime's XCom requests (SetXCom, GetXCom, GetXComSequenceItem, GetXComSequenceSlice, DeleteXCom) and on the XComs it clears when a try starts. With the default BaseXCom, requests go to the API server unchanged.
  • The backend runs in a helper process, started per task the same way a Python task process is started (bare fork, or a new interpreter on macOS or with [core] execute_tasks_new_python_interpreter). So the long-lived worker process keeps none of the backend's state, such as a cached S3FileSystem that a Python task forked from it later could not use.
  • Runtimes get what the default backend would give them: the value is decoded with serde before store_value, and a loaded value is encoded with serde again. skipmixin_key bypasses 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.
  • A backend call that fails fails the task. XCom that cannot be read or purged fails the task, as it does for a Python task. If the server stops the task or its process exits while the supervisor clears XComs, the supervisor stops waiting and does not start the task.
  • The backend looks up Connections and Variables through the supervisor's API client.
  • The supervisor services that process from the same request loop as the task, so a backend call blocks neither the loop nor its heartbeating, and a task whose backend hangs still stops at its execution_timeout.
  • A backend call that fails — the backend could not run, or refused, the XCom — reaches the runtime as its own XCOM_BACKEND_ERROR rather than API_SERVER_ERROR, which would point a user at the API server instead of at their own backend.
  • The Java SDK moves to supervisor schema 2027-02-28, so it requires Airflow 3.5.0, like the Go and TypeScript SDKs.
  • A new lang_sdk_xcom_object_storage e2e mode runs a Dag definition in each of TypeScript, Go and Java with XComObjectStorageBackend on 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:

[core]
xcom_backend = airflow.providers.common.io.xcom.backend.XComObjectStorageBackend

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: exit
Loading

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Claude Code (Opus 5.5) following the guidelines

@jason810496
jason810496 force-pushed the feature/lang-sdk/xcom-backend-in-coordinator branch from 5fa6540 to e77b09a Compare October 20, 2026 06:20
@jason810496 jason810496 added this to the Airflow 3.4.0 milestone Oct 20, 2026
@jason810496 jason810496 self-assigned this Oct 20, 2026
@jason810496
jason810496 force-pushed the feature/lang-sdk/xcom-backend-in-coordinator branch 3 times, most recently from 462f4c9 to 848611a Compare October 20, 2026 11:12
@jason810496
jason810496 marked this pull request as ready for review October 20, 2026 11:12
@ashb

ashb commented Oct 20, 2026

Copy link
Copy Markdown
Member

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

@jason810496

Copy link
Copy Markdown
Member Author

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:

  1. Fork safety. The supervisor runs inside the long-lived worker process (for example the Celery worker child), which also forks the Python task processes. A backend run there leaves its state in that process: XComObjectStorageBackend caches its fsspec filesystem (_STORE_CACHE in airflow.sdk.io.store), and a Python task forked from that process later fails with RuntimeError: This class is not fork-safe.
  2. The supervisor stays in control. A backend call blocks on I/O. In the supervisor, a hung upload would block the loop that heartbeats and enforces execution_timeout, with no way to interrupt it. In a separate process, the supervisor keeps heartbeating during the call, and kills the helper on execution_timeout, when the server stops the task, or after too many failed heartbeats.

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 BaseXCom never start it.

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 [workers] state_store_backend and the worker's secrets backends are next.

@Andrushika

Andrushika commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

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.

@jason810496
jason810496 marked this pull request as draft October 22, 2026 01:53
@jason810496
jason810496 force-pushed the feature/lang-sdk/xcom-backend-in-coordinator branch from 848611a to a0675cc Compare October 22, 2026 04:34
@jason810496
jason810496 force-pushed the feature/lang-sdk/xcom-backend-in-coordinator branch from 4c2fbf6 to c5f8103 Compare November 9, 2026 08:48

@jason810496 jason810496 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review.
I just addressed all the comments and squad some of the commits.

Comment thread java-sdk/capabilities.yaml Resolved
@jason810496
jason810496 marked this pull request as ready for review November 9, 2026 11:39
@jason810496
jason810496 requested a review from uranusjr November 9, 2026 11:39

@shivaam shivaam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two questions about API error reporting and startup cleanup.


Drafted-by: Codex (GPT-6) (no human review before posting)

@jason810496
jason810496 force-pushed the feature/lang-sdk/xcom-backend-in-coordinator branch from c5f8103 to 2343a9b Compare November 10, 2026 08:17
@uranusjr

Copy link
Copy Markdown
Member

Looks like there’s rebase accident. The squash commit 0f21d36 reverts #76727 , which is the PR's own base commit.

@jason810496 jason810496 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review.

@jason810496
jason810496 requested a review from shivaam November 10, 2026 08:31
@jason810496
jason810496 force-pushed the feature/lang-sdk/xcom-backend-in-coordinator branch from 2343a9b to f9759b4 Compare November 11, 2026 03:26
@jason810496

jason810496 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member Author

Looks like there’s rebase accident. The squash commit 0f21d36 reverts #76727 , which is the PR's own base commit.

Fixed in 2d46e70, I didn't realize in the last round, thanks.

@jason810496
jason810496 force-pushed the feature/lang-sdk/xcom-backend-in-coordinator branch from f9759b4 to 2d46e70 Compare November 11, 2026 03:35

@shivaam shivaam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Tested it as well.

@jason810496 jason810496 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review.

@jason810496
jason810496 requested a review from uranusjr November 12, 2026 04:56
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.
@jason810496
jason810496 force-pushed the feature/lang-sdk/xcom-backend-in-coordinator branch from 7a13d64 to d540af6 Compare November 12, 2026 08:10
@jason810496
jason810496 enabled auto-merge (squash) November 12, 2026 08:25

@jason810496 jason810496 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just rebased again to resolve the conflict and checked there isn't any rebase corruption before enabling auto-merge.

@jason810496
jason810496 merged commit 30f51ff into apache:main Nov 12, 2026
164 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle custom xcom backends with go sdk (edge mode)

5 participants