Skip to content

Fix DeadlockImminentError in async Connection resolution - #72079

Closed
saitejabandaru-in wants to merge 1 commit into
apache:mainfrom
saitejabandaru-in:fix-71891-async-get-conn
Closed

saitejabandaru-in wants to merge 1 commit into
apache:mainfrom
saitejabandaru-in:fix-71891-async-get-conn

Conversation

@saitejabandaru-in

Copy link
Copy Markdown

Closes #71891.

Motivation

A DeadlockImminentError is raised in Airflow 3 when resolving a connection inside an async task (e.g. via await BaseHook.aget_hook(...)). The Connection.async_get() method resolves the connection and saves it to SecretCache. The cache attempts to save the URI via the synchronous get_uri() method, which deserializes extra using extra_dejson.

The extra_dejson property iteratively loops over the dict and masks secrets using mask_secret, which triggers a synchronous IPC call (comms.send()) to the task supervisor. Since this executes inside the asyncio event-loop thread, it throws DeadlockImminentError and crashes the loop.

Changes

  • Implemented aextra_dejson and aget_uri on Connection to do the same but natively await the existing async masking utility (amask_secret).
  • Updated _async_get_connection in the execution environment's context to await conn.aget_uri() when saving to the SecretCache.

When fetching a connection in an async context, `Connection.async_get()` builds the connection and caches its URI. The sync `get_uri()` internally accesses `extra_dejson`, which parses and masks secrets using a synchronous IPC call (`mask_secret`), thereby blocking the async event loop and throwing `DeadlockImminentError`.\n\nThis adds `aextra_dejson` and `aget_uri` coroutines to `Connection` that use the asynchronous `amask_secret` variant, and updates the task execution context to await `aget_uri` when caching.
@vatsrahul1001

Copy link
Copy Markdown
Contributor

@saitejabandaru can you fix CI ?

@kaxil

kaxil commented Sep 10, 2026

Copy link
Copy Markdown
Member

Duplicate of #71890

@kaxil kaxil marked this as a duplicate of #71890 Sep 10, 2026
@kaxil kaxil closed this Sep 10, 2026
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.

DeadlockImminentError is raised when a connection is resolved inside an async task

4 participants