Skip to content

Support durable execution in Databricks task operators - #76295

Merged
amoghrajesh merged 8 commits into
apache:mainfrom
astronomer:durable-execution-databricks-taskbaseoperator
Nov 16, 2026
Merged

amoghrajesh merged 8 commits into
apache:mainfrom
astronomer:durable-execution-databricks-taskbaseoperator

Conversation

@amoghrajesh

Copy link
Copy Markdown
Contributor

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

DatabricksNotebookOperator and DatabricksTaskOperator now reconnect to a run they already submitted instead of submitting a new one after a worker crash.

Before this change, a worker that died during the poll loop left the Databricks run executing with no Airflow task watching it, and the retry called runs/submit again. Two runs, two bills, one of them orphaned. DatabricksSubmitRunOperator and DatabricksRunNowOperator already guard against this through ResumableJobMixin; these two did not.

DatabricksTaskBaseOperator now mixes in ResumableJobMixin and implements the six hooks it needs. The run id goes to the task state store before polling starts, so on retry the operator asks Databricks about the stored
run and either reconnects to it, returns early if it already succeeded, or submits fresh if it failed terminally.

Scope

Only the standalone path. Inside a DatabricksWorkflowTaskGroup the run is submitted by the .launch task and the run id reaches each leaf through xcom, so a retry already reconnects to the shared run. That branch of execute() keeps its existing behaviour, and a test pins it.

Two sentences in notebook.rst and task.rst claimed that "each retry submits a new Databricks run" for a standalone operator. Both now describe what the operator does.

Compatibility

durable defaults to True, so existing Dags pick up reconnection with no change. Pass durable=False to keep submitting a new run on every retry.

On Airflow below 3.3 the common.compat stand-in takes over and the operators behave as they did before, since the task state store does not exist there. The provider already imports the mixin through common.compat.sdk, so nothing new enters the dependency surface.

Testing

Using this Dag:

from __future__ import annotations

from datetime import datetime, timedelta

from airflow.providers.databricks.operators.databricks import (
    DatabricksNotebookOperator,
    DatabricksTaskOperator,
)
from airflow.sdk import DAG

CONN_ID = "databricks_default"
NOTEBOOK_PATH = "/Users/amoghdesai.oss@gmail.com/sleepy"

with DAG(
    dag_id="databricks_durable_manual",
    schedule=None,
    start_date=datetime(2024, 1, 1),
    catchup=False,
    default_args={"retries": 2, "retry_delay": timedelta(seconds=30)},
    tags=["manual", "durable"],
):
    DatabricksNotebookOperator(
        task_id="notebook",
        databricks_conn_id=CONN_ID,
        notebook_path=NOTEBOOK_PATH,
        source="WORKSPACE",
        polling_period_seconds=10,
    )

    DatabricksTaskOperator(
        task_id="task",
        databricks_conn_id=CONN_ID,
        task_config={"notebook_task": {"notebook_path": NOTEBOOK_PATH, "source": "WORKSPACE"}},
        polling_period_seconds=10,
    )

For both the tasks try 1:

image image

Killed the worker right after

State store for both:

image image

Try 2 for both

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

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


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@kaxil
kaxil force-pushed the durable-execution-databricks-taskbaseoperator branch from d983bdf to 96ec193 Compare November 4, 2026 01:51
@amoghrajesh
amoghrajesh force-pushed the durable-execution-databricks-taskbaseoperator branch from 96ec193 to 61cb957 Compare November 4, 2026 05:57
@amoghrajesh

Copy link
Copy Markdown
Contributor Author

Thnx for detailed reviews, merging this one.

@amoghrajesh
amoghrajesh merged commit 8a016b7 into apache:main Nov 16, 2026
76 checks passed
@amoghrajesh
amoghrajesh deleted the durable-execution-databricks-taskbaseoperator branch November 16, 2026 04:55
@shahar1 shahar1 mentioned this pull request Nov 18, 2026
1 task done
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.

4 participants