Atitit Lifting Database Deadlock processing summary

Source: Internet
Author: User

Atitit Lifting Database Deadlock processing summary

In normal terms, the lock is self-motivated. No official.
Normally, insert does not need to add rowlock, it is the default is Rowlock,


#-----The lock's own active conversion principle. (Normal ignore it, except ALTER TABLE field)
When a transaction exceeds its upgrade threshold, the database may proactively escalate row and page locks to table locks.



Like what. When you run a table transaction on a row, the database proactively acquires locks on the affected rows. At the same time, higher-level intent locks are placed on pages and tables that include these rows. All related index pages will also be locked at the same time. When the number of locks held by the firm exceeds its threshold, it attempts to change the intent lock on the table to a stronger lock. Like what. Intent Exclusive (IX) locks can be changed to exclusive (X) locks. When a stronger lock is obtained, all page-level and row-level locks held by the transaction on the table are freed.



Author of Old Wow's Paw attilax Ayron, email:[email protected]
Reprint please indicate source: Http://blog.csdn.net/attilax

#-------Transactions and deadlocks

The transaction lengthens the processing process and increases the chance of deadlock.
It's not that you can't use transactions,,, you should use transactions or you should use transactions ... Use sync to solve deadlocks at the same time.


#------Resolve Deadlocks

Default state ha, only in the same record for the same time when the change, it may be deadlock ...

and file ya 10, add a sync sync inside the code go OK LAN

Non-important items, direct only update operation sync Walk OK ...


#------Resolution of Deadlocks (supplementary method)

Code leaks are unavoidable, and must be caught with both hands ...
Client, on its own initiative to close timeout Conn, as if the timeout transaction does not take effect. Just good yourself write GC outtime ...
Server, set conn timeout, and lock timeout ...
The watchdog must be. Query lock or long time sql, kill ....



Atitit Lifting Database Deadlock processing summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.