psycopg / psycopg2

PostgreSQL database adapter for the Python programming language
https://www.psycopg.org/
Other
3.36k stars 505 forks source link

Issue: problem with patroni cluster #1610

Closed namluucong closed 1 year ago

namluucong commented 1 year ago

I have problem with patroni cluster

ERROR: Exception when working with leader
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/patroni-3.0.2-py3.6.egg/patroni/postgresql/rewind.py", line 69, in check_leader_is_not_in_recovery
    with get_connection_cursor(connect_timeout=3, options='-c statement_timeout=2000', **conn_kwargs) as cur:
  File "/usr/lib64/python3.6/contextlib.py", line 81, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.6/site-packages/patroni-3.0.2-py3.6.egg/patroni/postgresql/connection.py", line 43, in get_connection_cursor
    conn = psycopg.connect(**kwargs)
  File "/usr/local/lib/python3.6/site-packages/patroni-3.0.2-py3.6.egg/patroni/psycopg.py", line 42, in connect
    ret = _connect(*args, **kwargs)
  File "/usr/local/lib64/python3.6/site-packages/psycopg2/__init__.py", line 121, in connect
    dsn = _ext.make_dsn(dsn, **kwargs)
  File "/usr/local/lib64/python3.6/site-packages/psycopg2/extensions.py", line 167, in make_dsn
    parse_dsn(dsn)
psycopg2.ProgrammingError: invalid dsn: invalid connection option "target_session_attrs"

it still can connect to cluster but not sync data from leader node

and etcdctl cluster have error: 
"msg":"retrying of unary invoker failed","target":"etcd-endpoints://0xc0001f6000/10.60.64.18:2379","attempt":0,"error":"rpc error: code = DeadlineExceeded desc = context deadline exceeded"}

but i use IP: 127.0.0.1:2379 , it's OK

dvarrazzo commented 1 year ago

What version of psycopg2 are you using?

As far as I can see, target_session_attrs was added in libpq 10 and is not available in libpq 9.6.

If you are using the psycopg2-binary package, then it seems you are using something before psycopg2 2.7.3.2.

If you are using the psycopg2 package, then it's using your system libpq. In this case it means that the libpq version on your machine is older than 10.

You should upgrade the packages on your machines (Postgres currently supports from v11 on) or use a more up-to-date psycopg2-binary package.

namluucong commented 1 year ago

I update version psycopg to 2.7 but it still error psycopg2==2.9.7 psycopg2-binary==2.9.7

I dont know why

dvarrazzo commented 1 year ago

Uninstall both of them

Install only -binary.

On Wed, 16 Aug 2023, 14:17 NamLuu, @.***> wrote:

I update version psycopg to 2.7 but it still error psycopg2==2.9.7 psycopg2-binary==2.9.7

I dont know why

— Reply to this email directly, view it on GitHub https://github.com/psycopg/psycopg2/issues/1610#issuecomment-1680589181, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABQWBJRAX7MDKBWSFFHPPDXVTB7HANCNFSM6AAAAAA3Q4XX24 . You are receiving this because you modified the open/close state.Message ID: @.***>

namluucong commented 1 year ago

2023-08-18 10:09:31.738 +07 [14832] FATAL: requested timeline 20 is not a child of this server's history 2023-08-18 10:09:31.738 +07 [14832] DETAIL: Latest checkpoint is at B0/52000028 on timeline 15, but in the history of the requested timeline, the server forked off from that timeline at B0/5085A980.

I have other errors, can you help me? I try to remove wal_file but it not work for me

dvarrazzo commented 1 year ago

This is a server problem, not psycopg, and I cannot help for free. If you want a professional consultancy please contact privately.