From: chenyanfei <postgresql_2016@163.com>
To: pgsql-bugs@postgresql.org
Subject: Do we need to add parameter to libpq to set the TCP_SYNCNT parameter
Date: Tue, 6 Apr 2021 02:30:05 -0700 (MST)
Message-ID: <1617701405034-0.post@n3.nabble.com> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: postgresql_2016@163.com
Subject: Re: Do we need to add parameter to libpq to set the TCP_SYNCNT parameter
In-Reply-To: <1617701405034-0.post@n3.nabble.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox