title: How to use tcp_keepalives settings in Postgresql?
body: <p>Postgresql has 3 keepalive settings for managing dropped connections (in postgresql.conf):</p>
  
  <p>tcp_keepalives_count<br>
  tcp_keepalives_idle<br>
  tcp_keepalives_interval</p>
  
  <p>By default these are 0.</p>
  
  <p>The behavior I would like is for Postgresql to drop client connections after a period of time, should the client lose its network connection or go to sleep.</p>
  
  <p>I am currently using these values:</p>
  
  <p>tcp_keepalives_count = 1<br>
  tcp_keepalives_idle  = 60<br>
  tcp_keepalives_interval = 60  </p>
  
  <p>I am running PostgreSQL 8.4 on Mac OS X, but it doesn't seem to have any effect.  My test is that I lock a row in a table (using SELECT FOR UPDATE) and disconnect the workstation from the network.  But in Postgresql I still see that workstation holding the lock.</p>
  
  <p>I would expect that after the time has passed (60 seconds in this case) the connection would be terminated and the lock would be released.</p>
  
  <p>Either I am doing something wrong or I am completely misunderstanding how this is supposed to work.</p>
  
  <p>Any advice?</p>