title: PostgreSQL hangs on 'rollback transaction' with serializable transaction?
body: <p>We have a web service where all user facing read/write transactions are executed with isolation level SERIALIZABLE. However, we have been having problems where the transaction length of some connections goes through the roof and it seems that in majority (all?) cases the problem has been query <code>ROLLBACK TRANSACTION</code>. Connections stalling in this state are visible in <code>pg_stat_activity</code> table.</p>
  
  <p>Unless I've misunderstood something, rolling back a SERIALIZABLE transaction should always be successful without any kinds of locking and should require practically no resources to execute on PostgreSQL.</p>
  
  <p><strong>What could cause SERIALIZABLE transaction to hang on <code>ROLLBACK TRANSACTION</code>?</strong></p>
  
  <p>We're running connections through <code>pgbouncer</code> version 1.7 running on <code>localhost</code> using <code>pool_mode=transaction</code> in case that makes a difference. Running <code>select pg_terminate_backend(123)</code> where <code>123</code> is the offending connection does not immediately free the query from client's point of view. The client only sees anything 1h after the query and then I get response:</p>
  
  <pre><code>57P01 terminating connection due to administrator command
  08P01 server conn crashed?
  </code></pre>