Re: BUG #2576: tcp_keepalive doesn't work - Mailing list pgsql-bugs

From Fujii Masao
Subject Re: BUG #2576: tcp_keepalive doesn't work
Date
Msg-id 44E26C49.9060108@oss.ntt.co.jp
Whole thread Raw
In response to Re: BUG #2576: tcp_keepalive doesn't work  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #2576: tcp_keepalive doesn't work
List pgsql-bugs
Hi.

> You seem to have a misunderstanding of what tcp_keepalive is for.  It
> does not kill a backend that is in the midst of a query.  A backend will
> terminate when it is waiting for a client command and it sees that the
> connection has been lost --- which is what a TCP timeout will cause to
> happen.  But your example backends are not waiting for client commands.

No. In my example, there are backends that are waiting for client commands.

Please pay attention to the result of 'ps -ef | grep postgres'.

>> [terminal 4]
>> $ sleep 30
>> $ ps -ef | grep postgres
>> ...
>> postgres 16815 16782  0 17:06 pts/1    00:00:00 postgres: postgres sampledb
>> xx.xx.xx.xx(38738) idle in transaction
>> postgres 16816 16782  0 17:06 pts/1    00:00:00 postgres: postgres sampledb
>> xx.xx.xx.xx(38739) UPDATE waiting
>> postgres 16817 16782  0 17:06 pts/1    00:00:00 postgres: postgres sampledb
>> xx.xx.xx.xx(38740) UPDATE waiting
>> postgres 16818 16782  0 17:06 pts/1    00:00:00 postgres: postgres sampledb
>> xx.xx.xx.xx(38741) UPDATE waiting
>> postgres 16819 16782  0 17:06 pts/1    00:00:00 postgres: postgres sampledb
>> xx.xx.xx.xx(38742) UPDATE waiting
>> postgres 16820 16782  0 17:06 pts/1    00:00:00 postgres: postgres sampledb
>> xx.xx.xx.xx(38743) idle in transaction
>> postgres 16821 16782  0 17:06 pts/1    00:00:00 postgres: postgres sampledb
>> xx.xx.xx.xx(38744) UPDATE waiting
>> postgres 16822 16782  0 17:06 pts/1    00:00:00 postgres: postgres sampledb
>> xx.xx.xx.xx(38745) UPDATE waiting
>> postgres 16823 16782  0 17:06 pts/1    00:00:00 postgres: postgres sampledb
>> xx.xx.xx.xx(38746) idle
>> ...

'idle in transaction' backends don't terminate though they are waiting for
a client command and connection has been lost.

By the way, I ran strace for 'idle in transaction' backend.
-----
$ strace -p xxx
Process xxx attached - interrupt to quit
recv(7,
-----


best regards;

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: out of memory
Next
From: "Anita Lederer"
Date:
Subject: Re: out of memory