Is this a new bug in dbt v2.x compared to the latest version of dbt 1.x?
Current Behavior
With --generate-info-schema, dbt_rt.invocations holds every invocation except the current one, while dbt_rt.run_results already contains the current one's results. In a fresh project the table is empty.
A join from run_results to invocations therefore drops the current run.
Expected Behavior
dbt_rt.invocations includes the invocation that wrote the information schema.
Steps To Reproduce
dbt_project.yml
name: repro
version: "1.0.0"
profile: repro
profiles.yml
repro:
target: dev
outputs:
dev:
type: duckdb
path: repro.duckdb
models/m.sql
for i in 1 2 3; do
dbt build --generate-info-schema --invocation-id 00000000-0000-4000-8000-00000000000$i
done
cd target/info_schema/v1
duckdb -markdown -cmd ".read views.sql" -c "
select r.invocation_id, i.invocation_id is not null as in_invocations
from (select distinct invocation_id from dbt_rt.run_results) r
left join dbt_rt.invocations i using (invocation_id)
order by 1"
Relevant log output
| invocation_id | in_invocations |
|--------------------------------------|----------------|
| 00000000-0000-4000-8000-000000000001 | true |
| 00000000-0000-4000-8000-000000000002 | true |
| 00000000-0000-4000-8000-000000000003 | false |
All three builds exit 0 with no warnings or errors.
Environment
- OS: Windows 11
- CPU: x86
- dbt distribution and version: dbt 2.0.6 (same on 2.0.0)
Which database adapter are you using?
duckdb
Is this a discrepancy vs. dbt 1.x?
No (no information schema in 1.x).
Additional Context
Likely cause: write order. The invocation record is written after the command returns, but the information schema is written during it:
dbt docs generate already works around the same ordering with a second ingest (L2559-L2562); the general --generate-info-schema path has none. The run_results/invocations join in db.rs#L83 is affected the same way.
Is this a new bug in dbt v2.x compared to the latest version of dbt 1.x?
Current Behavior
With
--generate-info-schema,dbt_rt.invocationsholds every invocation except the current one, whiledbt_rt.run_resultsalready contains the current one's results. In a fresh project the table is empty.A join from
run_resultstoinvocationstherefore drops the current run.Expected Behavior
dbt_rt.invocationsincludes the invocation that wrote the information schema.Steps To Reproduce
dbt_project.ymlprofiles.ymlmodels/m.sqlRelevant log output
All three builds exit 0 with no warnings or errors.
Environment
Which database adapter are you using?
duckdb
Is this a discrepancy vs. dbt 1.x?
No (no information schema in 1.x).
Additional Context
Likely cause: write order. The invocation record is written after the command returns, but the information schema is written during it:
dbt_lib.rs#L258:do_execute_fs, which reachesexecute_all_phases→write_info_schemaat L2092dbt_lib.rs#L283:ctx.write(status), after it returnsdbt docs generatealready works around the same ordering with a second ingest (L2559-L2562); the general--generate-info-schemapath has none. Therun_results/invocationsjoin indb.rs#L83is affected the same way.