RE: Timeout parameters

From: "Jamison, Kirk" <k(dot)jamison(at)jp(dot)fujitsu(dot)com>
To: "Nagaura, Ryohei" <nagaura(dot)ryohei(at)jp(dot)fujitsu(dot)com>
Cc: "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>, 'Robert Haas' <robertmhaas(at)gmail(dot)com>, Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>, "MikalaiKeida(at)ibagroup(dot)eu" <MikalaiKeida(at)ibagroup(dot)eu>, "AYahorau(at)ibagroup(dot)eu" <AYahorau(at)ibagroup(dot)eu>, Michael Paquier <michael(at)paquier(dot)xyz>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: Timeout parameters
Date: 2019-03-26 08:25:14
Message-ID: D09B13F772D2274BB348A310EE3027C6486829@g01jpexmbkw24
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tuesday, March 26, 2019 2:35 PM (GMT+9), Ryohei Nagaura wrote:

>> Your patch applies, however in TCP_backend_v10 patch, your
>> documentation is missing a closing tag </varlistentry> so it could not be tested.
>> When that's fixed, it passes the make check.
>Oops! Fixed.

Ok. Confirmed the fix.
Minor nitpick, the semicolon is separated to another line when it shouldn't be.
+ This parameter is supported only on systems that support <literal>TCP_USER_TIMEOUT</literal>
+ ; on other systems such as Windows, it has no effect and must be zero.

Anyway, for now maybe wait for other reviewers to confirm the latest doc
before you update the patches again.

Documentations aside, I tested the patch and below are the results.

1.) apply OK, build OK, make check ok, install ok.

2.) Testing
A. Configuration Setting
[pg_hba.conf] Allow remote connection from client address
[postgresql.conf]
listen_addresses = '*'
# Optional just for checking logs in server
logging_collector = on

B. Tests
[Client-Side]
1. $ psql postgresql://USERNAME:PASSWORD(at)server_host:server_port/dbname?tcp_user_timeout=15000

2. postgres=# select inet_client_port();
inet_client_port
------------------
59396
3. (Via root user of client, other console window)
root# iptables -I INPUT -p tcp --dport 59396 -j DROP

4. postgres=# select pg_sleep(10);

5. Error output is displayed. Query is cancelled.
could not receive data from server: Connection timed out
postgres#=

#Inputting a query would attempt to reconnect to server

postgres=# select inet_client_port();
no connection to the server
The connection to the server was lost. Attempting reset: Succeeded.
postgres=#

6. Next test; tested again but switching #3 & #4
(Note: There should be a new client port number by then.)
postgres=# select inet_client_port();
postgres=# set tcp_user_timeout=15000;
postgres=# select pg_sleep(10);
root# iptables -I INPUT -p tcp --dport 59397 -j DROP

# Client hangs. Server could not receive data from client, so connection timed out.
# Need to reconnect again from client.
^Z
[3]+ Stopped

Below are the logs in the server.

[Server-Side Logs]
#Test#1
[12949] LOG: statement: select inet_client_port();
[12949] LOG: statement: select pg_sleep(10);
[12949] LOG: could not receive data from client: Connection timed out
#Test#2
[13163] LOG: statement: select inet_client_port();
[13163] LOG: statement: set tcp_user_timeout=15000;
[13163] LOG: statement: select pg_sleep(10);
[13163] LOG: could not receive data from client: Connection timed out

---
I also tested invalid keywords for tcp_user_timeout and errors were detected.
ERROR: invalid value for parameter "tcp_user_timeout": "kkk"
ERROR: -999 ms is outside the valid range for parameter "tcp_user_timeout" (0 .. 2147483647)

Regards,
Kirk Jamison

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2019-03-26 08:32:52 Re: [HACKERS] Block level parallel vacuum
Previous Message Tsunakawa, Takayuki 2019-03-26 08:21:20 RE: Speed up transaction completion faster after many relations are accessed in a transaction