We are using hiberante,c3p0, postgresql for the persistent layer. While running data intensive jobs, mostly select/insert, one of the developers decided to use entityManager.flush() before commit , like so
entityManager.getTransaction().begin()
insert n elements
entityManager.flush()
entityManager.getTransaction().commit()
After a while all of the threads running the data intensive jobs were seemingly blocked, and we discovered they were waiting on database connections form the pool. All the connections on the pool where in "Idle in transaction" state. The situation could be replicated every time.
After removing flush() the situation disappeared.
Does anyone have any idea why would this happen?
Thanks :D