Notes, tetherOps

Tethering dbt Cloud jobs: refreshing downstream projects in order

Why dbt Cloud jobs need an orchestrator, how tetherOps chains them across projects, and how it recovers when one breaks.

11 min read dbtOrchestration

In this article (6 sections)
  1. Why dbt jobs need orchestration
  2. Tethering jobs into pipelines
  3. Chaining pipelines across projects
  4. When a job breaks: Smart Retry
  5. Running it day to day
  6. Design choices and limits

A dbt project rarely lives alone. One team builds a data mart, and other teams build on top of it: reports, forecasts, exports to partners. Each of those is often its own dbt project, with its own jobs in dbt Cloud. The data is only right if they refresh in the right order, and only after the data they read from has finished refreshing.

tetherOps is an orchestrator for that. It tethers dbt Cloud jobs together: into pipelines, and pipelines into chains that can cross project and team boundaries. When an upstream refresh finishes, everything that depends on it refreshes next, in order. When something breaks, it re-runs only what failed and carries on. This note explains why that is needed and how it works.

Why dbt jobs need orchestration

One data mart, many consumers

Take a finance team that owns a dbt project building a finance data mart: cleaned orders, revenue and customer tables, refreshed every morning. Other projects read from it:

  • a finance reporting project that also needs the customer mart, owned by another team;
  • a forecasting project that only needs the finance mart;
  • a partner exports project that sends files built from the finance reports.

Each project is built by its own dbt Cloud job, or several. If forecasting runs before the finance mart has finished, it reads yesterday’s numbers, or a table halfway through being rebuilt. If partner exports runs before reporting, a partner gets a file that does not match the dashboard. Nothing errors; the data is quietly wrong.

The usual workarounds

Without an orchestrator, teams tend to choose one of three workarounds:

  • Schedule by the clock, with a buffer. The mart runs at 5:00, the reports at 6:30, “because the mart usually takes an hour”. On a fast day the reports wait for nothing. On a slow day they run too early. On a failed day they run on old data.
  • Merge everything into one big job. The order is guaranteed, but every team’s work is now one run. One failure stops everyone, and ownership gets blurred.
  • Adopt a general-purpose workflow platform. These are powerful, but they are a separate system to host, secure and learn, which is a lot for a team whose work is mostly dbt.

dbt Cloud can start one job when another finishes. What a setup like the one above needs on top of that is the picture of the whole chain: jobs that run side by side and wait for each other, projects that wait for several upstream projects, schedules that cope with missed runs, and a recovery that continues the chain instead of starting it again.

What tetherOps is

tetherOps adds that layer, and only that layer. It talks to the dbt Cloud API to trigger, watch and cancel runs, and to read the results of each run. Orchestrating dbt does not require any access to the data warehouse, so tetherOps stores only run metadata such as statuses, timings and the names of models that failed.

Tethering jobs into pipelines

The basic unit is a pipeline: an ordered list of stages, each holding one or more jobs.

Stage 1 · load raw data an ingestion sync Stage 2 · staging dbt Cloud job Stage 2 · snapshots dbt Cloud job, in parallel Stage 3 · finance mart starts when both have succeeded Pipeline complete pipelines that depend on it are told
Jobs in a stage run side by side; the next stage waits for all of them.
  • Jobs in a stage run in parallel. Staging and snapshots do not depend on each other, so there is no reason to run them one after the other.
  • A stage is a barrier. The next stage starts only when every job in the current stage has succeeded. If any fails, the pipeline stops there rather than building the mart on incomplete inputs.
  • Not only dbt. A stage can also start an ingestion sync in Fivetran or Airbyte, or call an HTTP endpoint, so the pipeline can begin where the data actually arrives rather than where dbt starts. A team can also add a SQL check against its warehouse; that is the one kind of step that connects to the warehouse, and only when a team sets it up.
  • Jobs come from dbt Cloud. tetherOps reads the list of projects and jobs from the dbt Cloud account. A pipeline refers to existing jobs; it does not redefine what they build.

Chaining pipelines across projects

Pipelines become a chain through dependencies. A pipeline can be set to run on the completion of one or more other pipelines, which may belong to different projects and different teams. This is the tether.

Finance mart project A · runs at 05:00 Customer mart project B · runs at 05:30 Forecasting after the finance mart Finance reporting waits for both marts Partner exports after finance reporting
Only the two marts have clock schedules. Everything below them runs when what it reads from is ready.

Waiting for the right parents

A downstream pipeline has one of two join rules:

  • Wait for all parents. Finance reporting starts only when both the finance mart and the customer mart have completed. This is the default, because most downstream work needs every input.
  • Wait for any parent. The pipeline starts as soon as one of its parents completes. This suits work that can use whichever source finished first.

The two marts in the example run on different schedules and finish at different times, so “completed” needs a definition. A parent’s run counts if it belongs to the same refresh as the child, or if it finished within the child’s time window (six hours by default) and after the child last ran. That second condition is what stops a report from running twice on the same data, or once on a mart that is a day old.

Keeping the chain safe

  • Failures stop at the right place. If a parent fails, its children are marked as upstream failed instead of running on stale inputs, and the marking passes down the chain. With “wait for any”, a child only fails if every parent failed.
  • No loops. A dependency that would create a cycle, where a pipeline ends up waiting on itself, is refused when it is added.
  • One refresh, one record. Every run that a chain triggers carries the same refresh identifier, so a whole morning’s refresh can be traced as one, rather than as a pile of separate runs.
  • Only the top needs a clock. In the example, only the two marts have schedules. The rest of the chain follows their completion, so when a mart finishes early, the reports run early too, and when it runs late, nothing reads it too soon.

Schedules that know what they missed

The pipelines at the top of a chain run on cron schedules. If the orchestrator was stopped when a run was due, for example during maintenance, each pipeline’s missed-run policy decides what happens when it comes back: skip the missed run, queue one run to start now, or catch up once.

When a job breaks: Smart Retry

In a long chain, one failure can hold up many teams. A dbt job can build hundreds of models, and when one fails, dbt skips everything downstream of it. Running the whole job again repeats every model that already succeeded, and the stages and pipelines after it keep waiting. Smart Retry re-runs only what failed, then continues the chain.

Reading what failed

Every dbt run produces a file called run_results.json, listing each model, test, seed and snapshot it touched, with a status. dbt Cloud keeps it for each step of a run. When a job run ends in an error, tetherOps reads that file and records the names of the nodes that errored (could not be built) or failed (a test found bad data). Nodes that were only skipped are left out, because they did not break; they were held back.

If a run failed before dbt produced any results, for example because of a connection problem, the list is empty, and tetherOps treats that as a different kind of failure instead of guessing.

Re-running only that

dbt lets a command select a node with a + after it, meaning “this node and everything downstream of it”. So the retry is one build that selects each failed node that way.

stg_customers stg_orders ✕ stg_payments customers orders (skipped) revenue (skipped) The retry builds only these three dbt build --select stg_orders+
Blue: the model that failed. Dashed: models skipped because of it. The other models already succeeded and are not run again.
  • The + brings back exactly what was skipped, and nothing that already succeeded.
  • build rather than run, so the retried models are tested again before anything downstream uses them.
  • The same job. tetherOps triggers the same dbt Cloud job with the retry command in place of its usual steps, so it uses the job’s environment and settings and appears in dbt Cloud’s run history next to the original.

A Smart Retry is refused when no failed nodes were recorded, when the run was already retried, when a newer run of the pipeline has started, or when the job is already running. Each of those would otherwise race with other work.

Continuing the chain

Stage 1 succeeds its jobs ran in parallel A job in stage 2 fails the pipeline run stops here Smart Retry the run resumes at stage 2 Stage 2 completes every job in it has succeeded Stage 3 runs then the pipeline completes Waiting pipelines start once all of their parents are done
Stage 1 is not repeated, and stage 2 re-runs only the job that failed.

Starting a Smart Retry creates the new job run and reopens the pipeline run at the failed stage in a single step, so the orchestrator never sees a half-reopened state and marks it failed again. Jobs in that stage that succeeded the first time still count. When the stage completes, the pipeline continues, and downstream pipelines that had been marked upstream failed go back to waiting, then run once all of their parents are done.

Retrying automatically

Each pipeline can also retry on its own, using the same Smart Retry with limits around it:

Setting Range Default Why
Attempts 0 to 5 per job, per run 0 (off) A failure that keeps repeating needs a person.
Backoff 0 minutes to a day 5 minutes Gives a lock or a late source time to clear.
Model failures only On or off On A failure with no failed models usually means an outage or an expired credential.

The attempt count is stored as attempts happen, so restarting the orchestrator does not reset it. Only one automatic retry runs at a time within a pipeline run, and cancelling a run also cancels any retry waiting for it.

Running it day to day

A chain that refreshes a company’s numbers every morning needs more than correct ordering. tetherOps also covers:

  • Alerts. Slack, a webhook or email when a pipeline fails, when a retry succeeds, and when a failed pipeline recovers, so the people who saw the failure also see the fix.
  • Deadlines. A pipeline can have a “done by” time and a maximum duration. If it is late, one alert goes out for that day, not one every minute.
  • Insights. Success rates, typical and slow run times, the slowest stages, and the models that fail most often, over 7, 30 or 90 days.
  • Pipelines as code. The whole setup can be exported to one YAML file and imported again, with a preview of every change first. An import applies completely or not at all, and it will not change a pipeline that is running.
  • People and access. Viewers can see everything; operators can run, cancel and retry; administrators manage users and the dbt Cloud connection. Sign-in can use single sign-on, and every change is recorded in an audit log.
  • An optional failure explainer that summarises the likely cause of a failed run using an AI model. It is off by default, and when turned on it sends only error text and run metadata, never warehouse data.

Design choices and limits

Choices that held up

  • Orchestrate, don’t rebuild. tetherOps refers to jobs that already exist in dbt Cloud and leaves the building to dbt. Teams keep owning their projects; the orchestrator only decides when each one runs.
  • Read the results file, not the logs. run_results.json is structured and produced by dbt itself, so Smart Retry does not depend on log formats.
  • Let dbt work out what is downstream. tetherOps names the failed nodes and lets dbt’s own selector find their children; dbt always knows the current model graph better than an outside tool.
  • Store as little as possible. Run metadata only, never warehouse data. The dbt Cloud API token is kept in memory and never written to disk.
  • Try it without an account. A built-in mock mode simulates dbt Cloud runs, failures and retries, so the whole flow can be explored without connecting anything.
  • Test the ordering logic hardest. About 140 automated tests cover stage barriers, joins, time windows, missed schedules, Smart Retry, the retry budget and alerts, because a mistake in ordering produces wrong data rather than an error.

Limits

  • Smart Retry is as precise as the results file. If a run fails before dbt records any results, there is nothing to select.
  • dbt Cloud only, for now. Running dbt Core projects with the same Smart Retry is planned but not built.
  • Dependencies are between pipelines, not individual models. A downstream pipeline waits for its parent to finish, even if the models it reads were not affected by that run.

tetherOps is live by invitation. The same engine also runs as tetherOps Hybrid, which keeps the dbt Cloud token on your own machine and reports to a shared website; that split is the subject of another note.


About the names. tetherOps is an independent project. It is not affiliated with or endorsed by dbt Labs, Inc., Fivetran or Airbyte. dbt and dbt Cloud are trademarks of dbt Labs, Inc.; Fivetran and Airbyte are trademarks of their owners. Project and model names in this note are illustrative.