Do we need to add parameter to libpq to set the TCP_SYNCNT parameter

From: chenyanfei <postgresql_2016(at)163(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Do we need to add parameter to libpq to set the TCP_SYNCNT parameter
Date: 2021-04-06 09:30:05
Message-ID: 1617701405034-0.post@n3.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

When we use the psycopg2 with green mode, which call postgres async
interfaces to make a connection, we ecnouter the conntion time too long when
we poweroff the server. Especially, if we use multihost, the connection time
is times longer.

Through the capture, we find the reason is because of the system parameter
tcp_retries2. In my env, the default value is 6, which will cost 127s to
give up a
connection.(https://github.com/torvalds/linux/blob/master/Documentation/networking/ip-sysctl.rst)

If use the sync connection method, I can set the connect_timeout parameter.

Through the linux document, I found we can set the tcp_retries2 parameter
with the TCP_SYNCNT parameter. So do we need to add parameter TCP_SYNCNT
like tcp_user_timeout?

>>> conn=psycopg2.connect(database="postgres",user="postgres",host="XXX",port="35432",
>>> tcp_user_retry=1);
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-x86_64/egg/psycopg2/__init__.py", line 127, in
connect
psycopg2.OperationalError: connection to server at "XXX", port 35432 failed:
Connection timed out
Is the server running on that host and accepting TCP/IP connections?

--
Sent from: https://www.postgresql-archive.org/PostgreSQL-bugs-f2117394.html

Browse pgsql-bugs by date

  From Date Subject
Next Message Karl Burkett 2021-04-07 00:57:39 PG 13.2 working with postgresql-13-setup
Previous Message Peter Eisentraut 2021-04-06 05:48:21 Re: Since '2001-09-09 01:46:40'::timestamp microseconds are lost when extracting epoch