Skip to content

fix: use psycopg2 instead of psycopg2-binary to link against system libpq#370

Open
vlsi wants to merge 1 commit intomainfrom
fix/psycopg2-libpq-version
Open

fix: use psycopg2 instead of psycopg2-binary to link against system libpq#370
vlsi wants to merge 1 commit intomainfrom
fix/psycopg2-libpq-version

Conversation

@vlsi
Copy link
Copy Markdown
Collaborator

@vlsi vlsi commented Mar 29, 2026

psycopg2-binary bundles its own libpq 9.6, which does not support the target_session_attrs connection parameter (requires libpq >= 10).

This causes Patroni replicas to log errors every second:
psycopg2.ProgrammingError: invalid dsn: invalid connection option "target_session_attrs"

The error originates in Patroni's rewind.py check_leader_is_not_in_recovery(), which sets target_session_attrs='read-write' for PG >= 10.

Switching to psycopg2 (non-binary) compiles from source against the system's libpq-dev, which fully supports the parameter. libpq-dev is already present via the postgresql-server-dev dependency.

…ibpq

psycopg2-binary bundles its own libpq 9.6, which does not support the
target_session_attrs connection parameter (requires libpq >= 10).

This causes Patroni replicas to log errors every second:
  psycopg2.ProgrammingError: invalid dsn: invalid connection option "target_session_attrs"

The error originates in Patroni's rewind.py check_leader_is_not_in_recovery(),
which sets target_session_attrs='read-write' for PG >= 10.

Switching to psycopg2 (non-binary) compiles from source against the
system's libpq-dev, which fully supports the parameter.
libpq-dev is already present via the postgresql-server-dev dependency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vlsi vlsi added bug Something isn't working dependencies Pull requests that update a dependency file docker Pull requests that update docker code labels Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working dependencies Pull requests that update a dependency file docker Pull requests that update docker code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants