java - Does Hibernate automatically restart transactions upon deadlocking? -
A lot has been written about this topic:
- ... many more
I have received the last approved response specifically:
< P> If you are using inodb or any line-level transaction RDBMS, it is possible that any write transaction can cause a standoff, even in completely normal circumstances. Large tables, large writes, and long-term transaction blocks will likely increase the chance of deadlock. In your situation, maybe it's a combination of them.
This will mean that we can never stop them, but only to deal with them. is it true? I wonder if you can ever stop Deathlong with 1000 people on the website who call for DB operations.
Going to the topic does not yield any interesting results only one I found ():
Public RestartTransactionAdviser Method Interceptor Apply {Private Static Logger Log = Logger GetLogger (RestartTransactionAdviser.class); Public invocation call (method investment charge) throws throwsable returns (returning, 1); } Private Object Restart (method investment allocation, int effort) throttle {object roll = zero; Try {rval = invocation.proceed (); } Hold (exception e) {throwable thr = ExceptionUtils.getRootCause (E); If (thr == faucet) {throw e; } (String.getMessage ("thr.getMessage", "deadlock")} string utilities canteens (thr.getMessage), "try to restart transaction") || StringUtils.contains (thr.getMessage) ()) "Failed transaction resume")) {if (try> 300) {throw e; } Int Timeout = RandomUtils.nextInt (2000); Logs. Warne ("The transaction rolled back. Restarted the transaction."); Log.debug ("Speed for" + timeout); Log.debug ("Restart the transaction: charge = [" + invocation + "], try = [" + try + "]"); Thread.Sleep (timeout); Attempt ++; Restart the return (greetings, attempts); } And {throw e; }} Return Ravel; }}
On the other hand, I doubt the quality of such solutions seriously. Can you tell in detail and tell what would be the best of the deadlock? How is deal with deadlock in banks and enterprise applications?
The Hibernate session emphasizes a first level cache. This allows you to post in the last responsible moment after posting, thus reducing the gap between lock acquisition (even if it is happening).
This means that you have to reduce the time of all the transactions and I can recommend using it for such efforts. To improve the scalability, to reduce the locking gap, you need to make sure that all the transactions are as low as possible.
Locking introduces the serial operation, and accordingly, the scalability is proportional to the total serial operating part. / P>
My advice is to work first on reducing the interval of the transaction. Indexing will reduce query time. I ORMs can generate awesome questions, so make sure that your Tools like
are very easy to satisfy your questions, so make sure you use it too.
When all transactions are possible and you still need more concurrency, you can move to horizontal scalability. You can start with a synchronous master-slope replication strategy first and you can redo the reset to the node slave while keeping the master to write.
Comments
Post a Comment