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