Skip to content

Fix test infrastructure: testing.postgresql 1.3.0 incompatible with PostgreSQL 17 on macOS ARM #119

Description

@myyong

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

  1. Replace testing.postgresql with pytest-postgresql — actively maintained, has explicit PostgreSQL 17 support. Requires migrating from unittest to pytest.

  2. 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).

  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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