| Just to make things clear, this is not a deadlock, but a saturated connection pool and high contention  If you decrease the timeout, a few transactions will fail in such a high traffic case, which is expected. The thing is, that after a transaction failed, the connection is released to the connection pool and another transaction can then pick up the connection for the sequence fetching. That's simply what you get when you overload your system which is apparently the case. You should definitely increase the connection pool size to a value that fits your needs. Try to increase the value until it works for your highest traffic case. Just keep in mind that increasing the value will not always work. At some point you will hit one or the other hardware limit. Using "hilo" obviously is a way to improve the situation and in general a good optimization, but it won't fix the underlying problem of your system just not being able to provide your application with enough connections. That you can only fix by increasing the connection count. As far as I know, Hibernate has no setting for providing a custom data source for that identifier generation strategy. You'd probably have to implement your own solution for that. Try extending the SequenceStyleGenerator to use e.g. a JNDI lookup for a dedicated connection pool maybe. |