Skip to content

Fix AsyncToSync error in Databricks deferrable operators on Airflow 3.0 - #74406

Merged
eladkal merged 2 commits into
apache:mainfrom
moomindani:fix-databricks-async-connection-71525
Oct 7, 2026
Merged

eladkal merged 2 commits into
apache:mainfrom
moomindani:fix-databricks-async-connection-71525

Conversation

@moomindani

@moomindani moomindani commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

On Airflow 3.0.x every deferrable Databricks operator fails in the triggerer with RuntimeError: You cannot use AsyncToSync in the same thread as an async event loop, because the hook resolves its connection with the sync get_connection from the trigger's event loop.

The hook now fills its databricks_conn cache through get_async_connection(..., hook=self) before the first async API call, so the existing sync helpers read the cached connection. This takes over #71840 (the original author is credited as co-author); the async twins of the sync helpers from that PR are not needed with this approach.

The common-compat dependency is marked # use next version so the release manager raises its floor: the hook= argument of get_async_connection first shipped in common-compat 1.17.0.

Verified against a real Databricks workspace (deferrable DatabricksRunNowOperator, DB-backed connection, official images): 3.0.6 fails with provider 7.21.0 and succeeds with this change; 3.1.0 and 3.2.2 also succeed with this change.

Not covered here: reading conn.extra_dejson from async code can still raise DeadlockImminentError when another trigger's asend is in flight. The fix is get_async_extra_dejson (#74147), which is not in a released common-compat yet.

closes: #71525
supersedes: #71840


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

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

This pull request and its description were written by Claude Code.

moomindani and others added 2 commits October 8, 2026 01:28
On Airflow 3.0 the triggerer cannot run the synchronous connection lookup
on its event loop, so every deferrable Databricks operator failed as soon
as its trigger made the first API call. The connection is now fetched
asynchronously once per hook, which also keeps the existing sync helpers
usable from the async code path.

The hook argument of get_async_connection first shipped in
common-compat 1.17.0, hence the raised floor.

closes: apache#71525

Co-authored-by: Saiteja Bandaru <saitejabandaru@users.noreply.github.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Only release managers may raise provider dependency floors; the
"use next version" marker asks them to pin the next common-compat
release, which already includes the hook argument of
get_async_connection.

Co-authored-by: Isaac <no-reply@databricks.com>
@moomindani
moomindani force-pushed the fix-databricks-async-connection-71525 branch from fa1a1b4 to 4a2bdd3 Compare October 7, 2026 16:29
@eladkal
eladkal merged commit 5718305 into apache:main Oct 7, 2026
54 of 55 checks passed
@moomindani
moomindani deleted the fix-databricks-async-connection-71525 branch October 8, 2026 01:25
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.

DatabricksRunNowOperator(deferrable=True) crashes in triggerer: AsyncToSync used inside running event loop (Airflow 3.0.6)

2 participants