What is blocking and how would you troubleshoot it?

What is blocking and how would you troubleshoot it?

Blocking occurs when a process has acquired lock on a set of rows, and another process is trying to acquire a lock on the same set of rows. In such a case, the other process has to wait until the first process finishes its job and releases the lock on the above said rows.

- Use sp_lock procedure to see type of locks acquired by various sessions on the server to find the cause of blocking.
- Problem is hinted by the WAIT status is a lot of rows that are returned as an output of sp_lock stored procedure execution.
- Use sp_who and sp_who2 to return more columns to get more information around the blocking.
- Use DBCC INPUTBUFFER (spid).This will show the last 128 characters of the last T-SQL statement executed from connection referred through spid. This way one can identify the stored procedure or application module that caused blocking.
- To resolve blocking, you can disconnect the connection causing the blocking using KILL command. If this does not solve the problem permanently, then rewrite the stored procedure/module causing the block more efficiently.

What is blocking and how would you troubleshoot it?

Blocking occurs when two or more rows are locked by one SQL connection and a second connection to the SQL server requires a conflicting on lock on those rows. This results in the second connection to wait until the first lock is released.

Troubleshooting blocking:
- SQL scripts can be written that constantly monitor the state of locking and blocking on SQL Server
- The common blocking scenarios must be identified and resolved.
- The scripts output must be checked constantly,
- The SQL profilers data must be examined regularly to detect blocking.
Different types of BACKUPs available in SQL Server
Different types of BACKUPs available in SQL Server - Complete database backup: This type of backup will backup all the information in the database. Used most commonly for disaster recovery and takes the longest time to backup........
What is database isolation in SQL Server?
What is database isolation in SQL Server? - Isolation in database defines how and when changes made by one transaction can be visible to other transactions......
What is a Schema in SQL Server 2005? Explain how to create a new Schema in a a Database?
What is a Schema in SQL Server 2005? - A schema is used to create database objects. It can be created using CREATE SCHEMA statement.......
Post your comment