Troubleshooting a SQL Server R2 deadlock

Source: Internet
Author: User

Problem scenario: In the customer that encountered a operation card dead phenomenon

Problem solving:

1, how to hook is a deadlock problem: through code tracing, the discovery is to execute a SQL statement timeout, so conjecture may be the table locked

2. If the confirmation is a matter of thought: Deadlock found through SQL, the following is the relevant SQL

Select request_session_id spid,object_name (resource_associated_entity_id) TABLENAME from sys.dm_tran_locks where Resource_type= ' OBJECT ' above this SQL is to query the current database of what deadlock, SPID for process ID, TABLENAME for table name PS: When Baidu has seen with SQL Tracker (SQL SERVER Profiler) can track out deadlocks
DBCC InputBuffer (SPID) finds the corresponding SQL based on the process ID, and with SQL you can confirm the location of the code 3. WORKAROUND: Change the database transaction ISOLATION level ALTER DB ng0001 set Read_ Committed_snapshot on with rollback immediate 4, Summary: This problem due to the relatively urgent plus is the night overtime, so there is no specific view of the lock category and the original database transaction isolation level, the SQL Server lock and Transaction isolation level these 2 knowledge points need to know more

Troubleshooting a SQL Server R2 deadlock

Related Article

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.