Post by Douglas Fabiano SpechtOla..
#tcp_keepalives_idle = 0
#tcp_keepalives_interval = 0
#tcp_keepalives_count = 0
[1]-http://www.postgresql.org/docs/9.3/static/runtime-config-connection.html
Douglas,
Executando o "man 7 tcp" (conforme consta lá no postgresql.conf) vc pode
ver:
<man 7 tcp>
tcp_keepalive_intvl (integer; default: 75; since Linux 2.4)
The number of seconds between TCP keep-alive probes.
tcp_keepalive_probes (integer; default: 9; since Linux 2.2)
The maximum number of TCP keep-alive probes to send before giving
up and killing the connection if no response is obtained from the other end.
tcp_keepalive_time (integer; default: 7200; since Linux 2.2)
The number of seconds a connection needs to be idle before TCP
begins sending out keep-alive probes. Keep-alives are sent only when the
SO_KEEPALIVE socket option is enabled. The default value is 7200 seconds
(2 hours). An idle connection is terminated after approximately an
additional 11 minutes (9 probes an interval of 75 seconds apart) when
keep-alive is enabled.
Note that underlying connection tracking mechanisms and application
timeouts may be much shorter.
</man 7 tcp>
Isso tudo quer dizer que essas configurações são para a checagem
(probes) que o SO faz para ver se socket está ativo (se o client não
morreu).
Sabe aquelas mensagens "unexpected EOF on client connection" ?? Pois é,
ocorrem quando um client morre mas o socket permanece ativo. Isso é
comum em aplicações cliente/servidor que mantém uma conexão persistente
com o banco de dados, pois o lado cliente pode morrer de forma
inesperada (queda de energia, falha no SO, rede, tia da faxina, etc...).
Então essas configurações servem para o SO fazer uma checagem e eliminar
sockets que estejam quebrados.
Então essas configurações *não servem* para o propósito de eliminar
sessões "idle", pois estão estão com o socket aberto e ok.
Agora na 9.3 com os "background workers" é possível ter um processo que
faça essa *limpeza*, e se não me engano alguém já implementou uma
extensão pra isso, só não lembro quem/onde. Se alguém souber colabore ai.
Att,
--
Fabrízio de Royes Mello Timbira - http://www.timbira.com.br/
PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento