title: Long lasting 'COMMIT' queries with 'idle' state in pg_stat_activity
body: <p>If I query:</p>
  
  <pre><code>select * from pg_stat_activity where application_name ~ 'example-application';
  </code></pre>
  
  <p>I get many rows which state is <code>idle</code> and query is <code>COMMIT</code>. They are long lasting and do not disappear. After some time, my application reach <code>hibernate.c3p0.max_size</code> (maximum number of JDBC connections in the pool) limit and stops working with database. </p>
  
  <p>Some application implementation details are described in other SO thread:
  <a href="https://stackoverflow.com/questions/43919411/guice-dao-provider-in-thread-pool-queries-become-idle-in-transation">Guice DAO Provider in thread pool - queries become &#39;idle in transation&#39;</a></p>
  
  <p>Why does it happen? How to solve this problem? </p>