psycopg / psycopg2

PostgreSQL database adapter for the Python programming language

Home Page:https://www.psycopg.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue: problem with patroni cluster

namluucong opened this issue · comments

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

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.

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

I dont know why

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

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