views:

29

answers:

0

We are using Spring 2.0, Hibernate 3.2, and PostgreSQL 8.4.2 with pgBouncer (we've also tried pgPool-II).

We are occasionally getting "IDLE in transaction" queries which sit around and hang up our database ... they usually show up sometime in between 2:00am and 6:45am.

I've been running into a lot of conflicting information online as to what the issue is, but have found this article, ... which implies that all of the transactions (including SELECT statements) must be wrapped in a transaction.

We are currently reading/writing to Hibernate by extending the HibernateDaoSupport, and are using getHibernateTemplate.saveOrUpdate() and getSession() from this class.

For example:

return (List) getSession().createQuery("from AttendanceBlock ab where ab.allocatedDate = :date and ab.location.id = :locationId and deleted = false").setParameter("date", date).setParameter("locationId", locationId).list();

My concern is that running this outside of a transaction may be leading to the IDLE in transaction's (which quickly block other transactions on our database).

However, other information online claims that Spring is (as-of 2.0) able to handle the transactions.

Is the way that we're using Hibernate / Spring leading to these Idle in transactions, or is it likely something else?