Skip to content

Test get_async_extra_dejson against the real supervisor comms - #74166

Merged
dabla merged 4 commits into
apache:mainfrom
dabla:fix/common-compat-async-extra-dejson-airflow-3-1
Oct 4, 2026
Merged

dabla merged 4 commits into
apache:mainfrom
dabla:fix/common-compat-async-extra-dejson-airflow-3-1

Conversation

@dabla

@dabla dabla commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #74147: a test of get_async_extra_dejson() against the real supervisor comms of the installed Airflow, instead of mocks.

The helper exists because the Task SDK's supervisor channel differs between Airflow versions (asend(), thread and async locks, Connection.aextra_dejson()). A mocked channel only encodes assumptions about those differences; this test forks a real task process talking to the real supervisor (as the Task SDK's own supervisor tests do, only the Execution API client is stubbed) and, from an event loop, resolves a connection and reads its extra in 50 concurrent coroutines over 3 rounds. It asserts the task process succeeds, every read returns the extra, and the decoded extra was masked through the supervisor. As provider tests run against each supported Airflow version, every compat job checks the helper against that version's comms.

It runs on Airflow 3.2+, the first version where a task process can call the supervisor from async code: before that, task-process asend() is not implemented (3.1) or absent (3.0), and async code only runs in the triggerer, whose channel serializes every request — a worker thread's synchronous send included — through asend() and an asyncio.Lock.

Verified locally:

Airflow Helper as merged Helper reading extra_dejson synchronously on the loop
main pass fails with DeadlockImminentError (MaskSecret)
3.2.2 pass —
3.1.8 skipped —

An earlier version of this PR changed the helper to skip the worker-thread fallback on Airflow 3.0/3.1; running against the real comms showed that fallback is safe there (see above), so that change was reverted and only the test remains. The forked child also resets asgiref's shared sync_to_async executor, which it would otherwise inherit from the pytest process (started by earlier tests) without its thread.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Opus 5.5

Generated-by: Claude Opus 5.5 following the guidelines

… 3.0 and 3.1

get_async_extra_dejson() falls back to running extra_dejson in a worker
thread when Connection.aextra_dejson() is missing. Its secret masking
sends to the supervisor, and on Airflow 3.0 and 3.1 the supervisor
channel has no thread lock: a send from a worker thread could interleave
with an asend() in flight on the event loop, e.g. in the triggerer. On
those versions the helper now deserializes Connection.extra without the
supervisor, as async hooks did before (apache#55179, apache#72130). The worker
thread stays for Airflow 3.2 to 3.3.1, whose channel is thread-safe, and
Airflow 2, which has no supervisor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@shahar1

shahar1 commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Please note the failing tests

dabla and others added 2 commits October 4, 2026 00:35
Revert the Airflow 3.0/3.1 json.loads branch: on those versions async
code only runs in the triggerer, whose channel serializes every request,
a worker thread's synchronous send included, through asend() and an
asyncio.Lock, so the worker-thread fallback was safe and kept the
masking. Instead, add a test that forks a real task process talking to
the real supervisor of the installed Airflow and reads extras
concurrently from an event loop, so each compat job checks the helper
against that version's comms rather than mocks. It needs Airflow 3.2+,
the first version where a task process can call the supervisor from
async code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dabla dabla changed the title Avoid the worker-thread fallback of get_async_extra_dejson on Airflow 3.0 and 3.1 Test get_async_extra_dejson against the real supervisor comms Oct 3, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dabla
dabla merged commit 043f97c into apache:main Oct 4, 2026
112 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.

2 participants