Skip to content

Segfault with DuckDB 1.5.1 when querying MySQL-attached tables via external materialization (regression from 1.5.0) #709

Description

@ernestorabhs

Summary

dbt-duckdb 1.10.1 segfaults when running an external model that queries MySQL-attached tables with DuckDB 1.5.1. The same setup works on DuckDB 1.5.0. Raw DuckDB 1.5.1 (without dbt) executes the same query without issues, so the crash is specific to how dbt-duckdb manages the connection/materialization.

Environment

  • dbt-duckdb: 1.10.1
  • dbt-core: 1.11.7
  • DuckDB: 1.5.1 (crash) / 1.5.0 (works)
  • Python: 3.12
  • Platform: Linux (Docker, python:3.12-slim)

Minimal reproduction

Requires Docker and a MySQL instance. Full self-contained repro:

# Start a MySQL container
docker run -d --name test-mysql -e MYSQL_ROOT_PASSWORD=testpass -e MYSQL_DATABASE=ds_views mysql:8

# Seed test data
docker run --rm --link test-mysql:mysql python:3.12-slim bash -c "
pip install -q duckdb==1.5.0
python3 << 'PY'
import duckdb
con = duckdb.connect()
con.install_extension('mysql')
con.load_extension('mysql')
con.execute(\"ATTACH 'host=mysql port=3306 user=root password=testpass database=ds_views' AS db (TYPE mysql)\")
con.execute('CREATE TABLE db.t1 (id BIGINT, name VARCHAR(50))')
con.execute('CREATE TABLE db.t2 (id BIGINT, value INTEGER)')
con.execute(\"INSERT INTO db.t1 SELECT i, 'row' FROM generate_series(1, 1000) t(i)\")
con.execute('INSERT INTO db.t2 SELECT i, i % 100 FROM generate_series(1, 1000) t(i)')
con.close()
PY
"

# Test with DuckDB 1.5.1 — CRASHES
docker run --rm --link test-mysql:mysql python:3.12-slim bash -c "
pip install -q dbt-duckdb~=1.10.1 duckdb==1.5.1
mkdir -p /tmp/dbt/models /tmp/parquet

cat > /tmp/dbt/profiles.yml << 'YML'
test:
  target: duckdb
  outputs:
    duckdb:
      type: duckdb
      path: /tmp/test.duckdb
      external_root: /tmp/parquet
      extensions: [mysql]
      settings: {threads: 4}
      attach:
        - path: 'host=mysql port=3306 user=root password=testpass database=ds_views'
          type: mysql
          alias: ds_views
          read_only: true
YML

cat > /tmp/dbt/dbt_project.yml << 'YML'
name: test
version: '1.0.0'
config-version: 2
profile: test
model-paths: ['models']
models:
  test:
    +materialized: external
YML

cat > /tmp/dbt/models/sources.yml << 'YML'
version: 2
sources:
  - name: ds_views
    database: ds_views
    tables: [{name: t1}, {name: t2}]
YML

cat > /tmp/dbt/models/test_model.sql << 'SQL'
SELECT t1.id, t1.name, t2.value
FROM {{ source('ds_views', 't1') }} AS t1
JOIN {{ source('ds_views', 't2') }} AS t2 ON t1.id = t2.id
SQL

cd /tmp/dbt && dbt build --profiles-dir . --project-dir .
"
# Exit code: 139 (SIGSEGV)

# Test with DuckDB 1.5.0 — WORKS
# Same as above but: pip install -q dbt-duckdb~=1.10.1 duckdb==1.5.0
# Exit code: 0, PASS=1

Observed behavior

DuckDB 1.5.1:

1 of 1 START sql external model main.test_model ......... [RUN]
Segmentation fault (core dumped)

Exit code: 139

DuckDB 1.5.0:

1 of 1 START sql external model main.test_model ......... [RUN]
1 of 1 OK created sql external model main.test_model .... [OK in 0.75s]
Completed successfully

Notes

  • The same JOIN query runs fine with raw DuckDB 1.5.1 Python API (no dbt) — even with identical settings (threads=4, storage_compatibility_version, COPY TO parquet)
  • Crash occurs with both read_only: true and read_only: false on the MySQL attach
  • DuckDB 1.5.1 was released 2026-03-23
  • Pinning duckdb==1.5.0 is a workaround

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions