Question

My problem is with my database.I use mssql 2005 and management studio. I can see blocked processes by using activity monitor and there i see a list of blocked processes. I killed process that blocked by using its process_id but this time another process is being blocked. I am killing but blocking is continues as a loop. Blocked process' attirubites are request mode=S request type=LOCK AND request status=GRAND. Is theere anyone to help me with this?

Was it helpful?

Solution

First of all, if a request is GRANTed, then it is not blocked; blocking occurs when a request is WAITing on a lock.

Second, when you look at which process is blocked by which, there is usually a hierarchy, for example, a SPID 63 is blocked by SPID 128, but SPID 128 is also being blocked by SPID 98, which is in turn blocked by SPID 101. What you need is to identify that last one, the head of the blocking chain, the one blocking others but not being blocked itself, and deal with it.

Here's a query that will help you identify the head blocker:

select r.session_id, r.host_name, r.program_name, 
    r.login_name, r.nt_domain, r.nt_user_name, 
    r.total_elapsed_time/1000 as total_elapsed_time_sec, getdate() as vrijeme,
    (select text from sys.dm_exec_sql_text(c.most_recent_sql_handle)) as sql_text
from sys.dm_exec_connections c 
inner join sys.dm_exec_sessions r on r.session_id = c.session_id
where r.is_user_process = 1
and exists (
    select *
    from sys.dm_os_waiting_tasks r2
    where r2.blocking_session_id = r.session_id
)
and not exists (
    select *
    from sys.dm_os_waiting_tasks r3
    where r3.session_id = r.session_id
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top