Sub topic 14
Repairing a failed run
This chapter assumes you know how tasks, dependencies, retries, and run_if rules work in a Databricks job. It covers what to do when a run fails after some tasks have already succeeded.
Why repair exists
Suppose the daily-sales-pipeline job runs ingest, transform, and publish in order. ingest succeeds, transform fails, and publish is skipped as "upstream failed". Starting a new run would repeat ingest, which may be slow or costly.
A repair run reruns only the tasks that failed or were skipped, plus anything that depends on them. Tasks that already succeeded keep their results. The repair is recorded as part of the original run, so the run's history stays in one place.
What a repair reruns
By default, a repair selects:
- Tasks that failed, timed out, or were canceled.
- Tasks that were skipped because an upstream task failed or a run_if rule was not met.
- Tasks downstream of any selected task.
You can also pick extra tasks to rerun, even ones that succeeded. This helps when a successful task read bad input and you want it rerun together with its dependents.
Repairing from the UI
- Open the job and select the failed run from the Runs tab.
- Choose Repair run.
- Review the list of tasks that will rerun. Add or remove tasks if needed.
- Optionally change the parameters for the repair.
- Start the repair.
The run page then shows each attempt for the repaired tasks. The run's overall status updates when the repair finishes.
Repairing through the API
The Jobs API has a runs/repair endpoint. It takes the run ID and the task keys to rerun.
{
"run_id": 455644833,
"rerun_tasks": ["transform", "publish"]
}You can set rerun_all_failed_tasks to true instead of listing task keys. Use one or the other, not both.
Behavior to know
- Task values are kept. A repaired
transformcan still readrow_countfrom the successfulingestthrough{{tasks.ingest.values.row_count}}. - Compute may be new. A job cluster is created again for the repair. Tasks do not continue on the old cluster, so anything held in memory or on local disk is gone.
- Repairs are not retries. Retries happen automatically inside one run. A repair is a manual or API-triggered action after the run has ended. Retries should run out first.
- Concurrency still applies. A repair counts as an active run. With
max_concurrent_runsset to 1, a repair can be blocked while another run is active. - Notebooks must be safe to rerun. A failed task may have written partial output. Prefer idempotent writes, such as
MERGEor overwriting a partition, so a repair does not duplicate rows. - Code changes are picked up. If you fix the notebook before repairing, the repair uses the current version for workspace notebooks. Notebooks from Git use the commit pinned in the run.
Exercise
In a job with ingest → transform → publish, ingest succeeds and transform fails. You fix the transform notebook and start a repair. Which tasks rerun by default, and why does the repaired transform still get the row_count value from ingest?
Show answer
Transform reruns because it failed, and publish reruns because it was skipped and sits downstream of transform. Ingest does not rerun. The repaired transform still gets row_count because ingest's task values are kept from the original run.