dbt run hangs on model compile with no error output
Diagnoses dbt runs that hang silently during compilation by rerunning with --debug to find the last action, then checking warehouse query history for a stuck query or binary-searching a runaway macro. Use when dbt run hangs with no error. Not for hangs with a visible error message.
TL;DR
A silent hang is either a warehouse query that never returns or a Jinja macro stuck in a loop. Rerun with --debug to see the last logged action: if it is a query, find and cancel it in the warehouse history; if it is macro rendering, binary-search the macro. Then fix the root cause and rerun.
Error
dbt run hangs on model compile with no error outputSteps
- Kill the hung run and rerun with
dbt run --debug --select [MODEL NAME], watching the last log line before it stalls. Expected: the last line names a query execution or a macro render. - If the last action is a query, open the warehouse query history and find the running query from the dbt session. Expected: you see the stuck query and its runtime.
- Cancel the stuck query in the warehouse, then investigate why it hung (missing join condition, cartesian product, or a huge scan). Expected: you find the query defect.
- If the last action is Jinja rendering, the hang is a macro loop: comment out half the macro logic and recompile to binary-search the culprit. Expected: you isolate the looping section.
- Fix the query or macro, then rerun normally. Expected: the run completes.
When to use
dbt runhangs indefinitely with no error output.- The hang is reproducible on the same model.
When not to use
- The run fails with an error message (follow that error instead).
- The whole machine is unresponsive (a resource problem, not a dbt problem).
Tool compatibility
- dbt Core 1.0 and later, all adapters.
--debuglogging is adapter-independent.
Variant phrasings
dbt compile hangs with no output
Same diagnosis without the run phase; the hang is in Jinja rendering.
dbt run stalls on one model while others finish
The hang is model-specific; select just that model to reproduce faster.
Why it happens
dbt logs each step as it goes, so a hang with no new output means the current step never finishes. Long-running warehouse queries and infinite Jinja loops are the two candidates, and the debug log distinguishes them.
Edge cases
- A missing join condition creates a cartesian product that runs for hours; the query history shows explosive row counts.
- Network stalls between dbt and the warehouse can mimic a hang; check connectivity if no query is running.
- Adapter query timeouts, when configured, turn hangs into errors; set one to fail fast in the future.
Provenance
Resolved from the public thread: https://vectle.com/posts/pstj8YrRprgPcOftJziyopcw
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.