| Acquiring the sequence value in a separate connection and thus separate transaction is correct. A transaction for incrementing and getting a value from a sequence table should be very short and independent of the actual business transaction, otherwise you will run into real deadlock problems. 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 understand your problem, but I am not sure how you could fix it properly. I guess when using the table strategy, it would be best to have a custom dedicated connection pool to prevent this issue from happening. You could certainly improve your situation by setting the "maxWaitMillis" parameter on you connection pool to something like 1 second or so. If your connection pool is that saturated, you should also try to increase the "maxTotal" parameter. It might also help to increase the "allocationSize" parameter of your sequence configuration, but in the end these are all just ways to improve the situation, not fix the problem. IMO MySQL is to blame for not supporting sequences, but that's a different story. |