#15724·dbt-core

[v2 Bug] `run_results.json` and `on-run-end` `results.execution_time` include connection-limit wait, unlike TUI and OTel

Author: datadersCreated Jul 29, 2026Updated Oct 1, 2026
Labelstype:bugartifactsengine:v2area:engine

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 / 1000

Steps To Reproduce

  1. Take a project with enough nodes to saturate the thread pool.
  2. dbt build --threads 4
  3. Compare, per node: run_results.json execution_time vs the elapsed time shown in interactive progress vs NodeProcessed.duration_ms from --otel-parquet-file-name spans.parquet.
  4. Sum execution_time across 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_time is stamped at fs/sa/crates/dbt-tasks-sa/src/runnable/runnable/mod.rs:110
  • the connection-limit gate .awaits at fs/sa/crates/dbt-tasks-core/src/task.rs:118, i.e. after that stamp
  • Stat carries only two wall-clock instants and no notion of wait (fs/sa/crates/dbt-common/src/stats.rs:82-93), so Stat::get_duration() folds the wait in
  • fs/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 ConnectionLimitWait span accumulates onto the ancestor node span at fs/sa/crates/dbt-common/src/tracing/middlewares/metric_aggregator.rs:177-192
  • NodeProcessed.duration_ms is 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_ms is readable from the ambient span, which is exactly how rows_affected is already backfilled onto Stat (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

  1. timing[] has no real execute window. stats_to_results.rs:16-27 sets the compile and execute sub-records to the same (start_time, end_time) pair, with // TODO: Differentiate between compile and execute timing. So timing cannot be used as a workaround for this bug — consumers that compute execute_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.
  2. Top-level elapsed_time is 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

markdown
- OS: Linux (k8s) and macOS
- dbt: 2.0.0-preview.190 (also reproduced on preview.200)
- dbt-core comparison: 1.10.x / 1.11.6

Which database adapter are you using with dbt?

Reported on Snowflake; the mechanism is adapter-independent.