Problem
123 tests error with RuntimeError: *** failed to launch Postgresql *** when running the test suite on macOS aarch64 with PostgreSQL 17 (Homebrew).
The PostgreSQL log shows:
FATAL: postmaster became multithreaded during startup
Root cause
testing.postgresql 1.3.0 (last updated 2019) starts PostgreSQL by running the postgres binary directly via subprocess.Popen. PostgreSQL 17 added a macOS-specific startup check (pthread_main_np()) that refuses to start if the process appears to have been launched from a multithreaded context. By the time unittest is running (which itself creates threads), every attempt to start a test PostgreSQL instance fails this check.
Environment where this occurs:
- macOS aarch64 (Apple Silicon)
- PostgreSQL 17.x (Homebrew)
- Python 3.12
testing.postgresql 1.3.0
Affected tests
All 123 tests in test classes that inherit from RequiresDBTestCase with database_type = TestPostgres (the default). DuckDB-based tests are unaffected.
Fix options
-
Replace testing.postgresql with pytest-postgresql — actively maintained, has explicit PostgreSQL 17 support. Requires migrating from unittest to pytest.
-
Subclass testing.postgresql.Postgresql to override start() and launch the postgres process via os.fork() + os.execvp() directly from a single-threaded context (avoids the posix_spawn path that Python 3.12 uses on macOS).
-
Downgrade PostgreSQL to 16.x for local development (workaround only).
Notes
- The DuckDB test path (
TestDuckDb) is unaffected and covers the same test surface for dialect-agnostic code.
- This issue pre-exists on the
mssql branch and is not introduced by the main merge.
Problem
123 tests error with
RuntimeError: *** failed to launch Postgresql ***when running the test suite on macOS aarch64 with PostgreSQL 17 (Homebrew).The PostgreSQL log shows:
Root cause
testing.postgresql1.3.0 (last updated 2019) starts PostgreSQL by running thepostgresbinary directly viasubprocess.Popen. PostgreSQL 17 added a macOS-specific startup check (pthread_main_np()) that refuses to start if the process appears to have been launched from a multithreaded context. By the timeunittestis running (which itself creates threads), every attempt to start a test PostgreSQL instance fails this check.Environment where this occurs:
testing.postgresql1.3.0Affected tests
All 123 tests in test classes that inherit from
RequiresDBTestCasewithdatabase_type = TestPostgres(the default). DuckDB-based tests are unaffected.Fix options
Replace
testing.postgresqlwithpytest-postgresql— actively maintained, has explicit PostgreSQL 17 support. Requires migrating fromunittesttopytest.Subclass
testing.postgresql.Postgresqlto overridestart()and launch thepostgresprocess viaos.fork()+os.execvp()directly from a single-threaded context (avoids theposix_spawnpath that Python 3.12 uses on macOS).Downgrade PostgreSQL to 16.x for local development (workaround only).
Notes
TestDuckDb) is unaffected and covers the same test surface for dialect-agnostic code.mssqlbranch and is not introduced by themainmerge.