[v2 Bug] `run_results.json` and `on-run-end` `results.execution_time` include connection-limit wait, unlike TUI and OTel
Is this a new bug in dbt v2.x compared to the latest version of dbt 1.x?
- I believe this is a new bug in dbt v2.x
- I have searched the existing issues and could not find a duplicate
Current Behavior
execution_time in run_results.json — and on the results object exposed to on-run-end hooks — includes time the node spent waiting at the connection-limit / backpressure gate. It measures node lifetime, not work.
This was fixed for the interactive progress display and dbt.log in #14477 / fs#10421 ("Exclude connection-limit wait time from node duration and show waiting nodes as idle in interactive progress"). The scoping was literal: that PR touched 16 files, none of them on the artifact path. So today there are three surfaces with two semantics:
| Surface | Semantics |
|---|---|
| Interactive progress (TUI) | net of wait ✅ |
OTel NodeProcessed.duration_ms |
net of wait ✅ |
run_results.json execution_time |
includes wait ❌ |
results.execution_time in on-run-end |
includes wait ❌ |
target/metadata/run/results/*.parquet execution_time |
includes wait ❌ |
Reported by a user who cut production over to 2.0.0-preview.190 on a 1,103-node project with threads: 4:
- a small daily reporting mart (~77 rows):
execution_time= 194.0s, actual warehouse work = 18.2s CTAS + sub-second grants,queue_time= 0 - view-materialized staging models with <1s of real warehouse time report ~260s
- Σ
execution_time= 525 min over 1,103 nodes against a ~33 min wall clock (dbt-core on the same project: 118 min / ~30 min) - WLM queue across the entire build was < 24s total, and Fusion issued fewer queries than dbt-core
Downstream impact: this value is loaded verbatim into Elementary's dbt_run_results table by its on-run-end hook, which is what its built-in Model Performance report reads. Post-cutover that report inflated +95% to +10,000% per model while actual throughput was unchanged. This affects every Fusion + Elementary user, not one customer.
Expected Behavior
execution_time should exclude connection-limit wait, matching what the TUI and OTel already report. Concretely, for any given node:
run_results.execution_time == NodeProcessed.duration_ms / 1000Steps To Reproduce
- Take a project with enough nodes to saturate the thread pool.
dbt build --threads 4- Compare, per node:
run_results.jsonexecution_timevs the elapsed time shown in interactive progress vsNodeProcessed.duration_msfrom--otel-parquet-file-name spans.parquet. - Sum
execution_timeacross all nodes and compare to invocation wall clock.
The divergence scales with how contended the connection pool is, so it is most visible on wide DAGs with low threads.
Root cause
RunTask deliberately opts out of the default outer backpressure gate and acquires the connection permit granularly inside execution:
start_timeis stamped atfs/sa/crates/dbt-tasks-sa/src/runnable/runnable/mod.rs:110- the connection-limit gate
.awaits atfs/sa/crates/dbt-tasks-core/src/task.rs:118, i.e. after that stamp Statcarries only two wall-clock instants and no notion of wait (fs/sa/crates/dbt-common/src/stats.rs:82-93), soStat::get_duration()folds the wait infs/sa/crates/dbt-tasks-core/src/stats_to_results.rs:11—let execution_time = stat.get_duration().as_secs_f64();
The wait is therefore inside the measured window by construction. Note this is unrelated to waiting on upstream nodes, which happens before line 110 — which is why the inflation tracks thread saturation rather than DAG depth.
The corrected value already exists in-process
This does not require reconstructing wait accounting. fs#10421 already built the aggregation:
- every
ConnectionLimitWaitspan accumulates onto the ancestor node span atfs/sa/crates/dbt-common/src/tracing/middlewares/metric_aggregator.rs:177-192 NodeProcessed.duration_msis already net (fs/sa/crates/dbt-tasks-core/src/task_spans.rs:328—let net_duration = duration.saturating_sub(idle_time_ms);)NodeEvaluated.idle_time_msis readable from the ambient span, which is exactly howrows_affectedis already backfilled ontoStat(fs/sa/crates/dbt-tasks-sa/src/runnable/runnable/mod.rs:515-519, then:548)
So the fix is to carry idle_time_ms onto Stat and subtract it in stats_to_results, reusing the existing rows_affected pattern.
Related, and worth fixing in the same area
timing[]has no real execute window.stats_to_results.rs:16-27sets thecompileandexecutesub-records to the same(start_time, end_time)pair, with// TODO: Differentiate between compile and execute timing. Sotimingcannot be used as a workaround for this bug — consumers that computeexecute_completed_at - execute_started_at(Elementary populates four columns from this) get the same inflated number, and there is no compile/execute split at all.- Top-level
elapsed_timeis a sum, not wall clock (fs/sa/crates/dbt-tasks-core/src/utils.rs:25-29), so it over-reports by roughly the thread count and compounds the same inflation. This is the "525 min vs 33 min" number above.
Environment
- OS: Linux (k8s) and macOS
- dbt: 2.0.0-preview.190 (also reproduced on preview.200)
- dbt-core comparison: 1.10.x / 1.11.6Which database adapter are you using with dbt?
Reported on Snowflake; the mechanism is adapter-independent.
Source: dbt-labs/dbt-core