| Unfortunately reducing the timeout doesn't help in this case. All other write threads aren't blocked waiting on a database connection, they're waiting on a lock on PooledOptimizer in the following stack trace: {{ at org.hibernate.id.enhanced.PooledOptimizer.generate(org.hibernate.id.enhanced.AccessCallback) (line: 70) at org.hibernate.id.enhanced.SequenceStyleGenerator.generate(org.hibernate.engine.spi.SharedSessionContractImplementor, java.lang.Object) (line: 432) at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(java.lang.Object, java.lang.String, java.lang.Object, org.hibernate.event.spi.EventSource, boolean) (line: 105) at org.hibernate.jpa.event.internal.core.JpaPersistEventListener.saveWithGeneratedId(java.lang.Object, java.lang.String, java.lang.Object, org.hibernate.event.spi.EventSource, boolean) (line: 67) at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(org.hibernate.event.spi.PersistEvent, java.util.Map) (line: 189) at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(org.hibernate.event.spi.PersistEvent, java.util.Map) (line: 132) at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(org.hibernate.event.spi.PersistEvent) (line: 58) at org.hibernate.internal.SessionImpl.firePersist(org.hibernate.event.spi.PersistEvent) (line: 773) at org.hibernate.internal.SessionImpl.persist(java.lang.Object) (line: 758)}} So, reducing the timeout just means that as soon as one transaction gives up, it errors out and the next one deadlocks, and so on. > Should other business transactions block just because you have a write lock on the sequence table in your first transaction? I don't think so. I agree that sounds distasteful, but not as distasteful as deadlocks. Do you see any reason that implementing a hi/lo strategy here wouldn't work? That way if the hilo incremented with (say) 100, only 1 in 100 creates would block this way. > it would be best to have a custom dedicated connection pool to prevent this issue from happening. I'm investigating this, but so far I haven't found any way of specifying a separate pool to be used by JdbcIsolationDelegate. |