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;

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

Reply via email to