Skip to content

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

Merged
anikin-aa merged 1 commit intomainfrom
fix/psycopg2-libpq-version
Apr 27, 2026
Merged

fix: use psycopg2 instead of psycopg2-binary to link against system libpq#370
anikin-aa merged 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
@anikin-aa anikin-aa merged commit 02093b2 into main Apr 27, 2026
36 of 38 checks passed
@anikin-aa anikin-aa deleted the fix/psycopg2-libpq-version branch April 27, 2026 06:54
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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