![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I found an error that tcp_keepalive doesn't work. |
#3
| |||
| |||
|
|
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. |
|
[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 ... |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
Linux-Kernel Archive: Re: 2.6.12.5 bug? per-socket TCP keepalive settings http://www.ussg.iu.edu/hypermail/lin...08.2/0757.html I'm confused whether tcp_keepalive problem should be solved at the DB level. |
#6
| |||
| |||
|
|
According to that, Linux keepalive starts working once you have either sent or received at least one byte over the connection. Therefore it's not possible to get past the authentication stage without keepalive being ready to go. And we do have a pretty short timeout on the auth stage (1 minute if memory serves). |
|
So I'm not seeing what problem we need to solve. |
|
In any case, if you don't like that behavior methinks you need to be lobbying some kernel hackers, not database weenies. Postgres is not in the business of second-guessing the TCP stack. |
#7
| |||
| |||
|
|
Because 'idle in transaction' backends that don't terminate by tcp_keepalive keep holding the lock. |
![]() |
| Thread Tools | |
| Display Modes | |
| |