Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion SP4 reports queries blocking on themselves?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Santeri Voutilainen [MSFT]  
View profile  
 More options May 19 2005, 2:42 pm
Newsgroups: microsoft.public.sqlserver.server
From: "Santeri Voutilainen [MSFT]" <sante...@online.microsoft.com>
Date: Thu, 19 May 2005 11:42:05 -0700
Local: Thurs, May 19 2005 2:42 pm
Subject: Re: SP4 reports queries blocking on themselves?
What you are seeing is not related to locks, rather it is related to the
latch waits you see in sysprocesses.  In SP4 we are able to determine the
blocking spid for latch waits when the blocking spid holds the latch in
exclusive or update mode.  In these cases the blocking spid information is
populated into the "blocked" field in sysprocesses.
So why is the spid blocked by itself?  Well, that has to do with how latches
are used for IO operations.  When an IO is issued for page, a latch is held
on the page.  Depending on the IO operation, the latch mode acquired is
shared (SH) or exclusive (EX).  The latch for the IO is acquired by the
thread that issues the IO.  Since all SQL Server IO operations are
asynchronous, if the spid that issued the IO wants to wait for the IO to
complete it will attempt to acquire another latch on the same page after
issuing the IO.  The first latch is released when the IO completes.  This
release allows the second latch request to be granted.
Here's an example of how this works:
1. Spid 55 wants to read page P1 which does not exist in the buffer pool.
2. Spid 55 acquires an EX latch on page P1 -- this marks spid 55 as owning
the latch.  The latch is in an in memory data structure, not the physical
page itself.  Since the page does not yet exist in memory the mode is EX in
order to force other spids that may also want to access the page to wait for
the IO to complete and also to prevent them from issueing a second IO
operation for the same page.
3. Spid 55 issues the IO request to read P1 from disk.
4. Since Spid 55 wants to read the page, it must wait for the IO to
complete.  It does this by attempting to acquire another latch (in this case
a share (SH)) latch on the page.  Since the latch is already held in EX, the
SH request is blocked and the spid is suspended.
5. Upon completion of the IO the EX latch on the page is released.
6. The release of the EX latch grants the SH latch to spid 55.
7. Spid 55 can now read the page.

For the duration between steps 4 (the SH latch acquire) and step 5 (EX latch
release) sysprocesses will indicate that spid 55 is blocked by itself with a
wait type of PAGEIOLATCH_XX (where XX can be SH, UP, or EX) as an indication
that it is waiting for the completion of an IO that it itself issued.

--
Santeri (Santtu) Voutilainen

This posting is provided "AS IS" with no warranties, and confers no rights.

"Jonathan Levine" <my...@nospam.nospam> wrote in message

news:7A8A5EF7-4459-40B4-99A7-0EDAE49DD8EF@microsoft.com...
> Adrian,

> Thanks for your reply.

> I'm currently working on updating the stats for my big tables.   I have
> had
> some update stats running for more than 24 hours -- is that normal?

> Here is an example of sp_locks and sysprocesses output for a query that
> took
> about an hour in sp3a, and is taking 5-10 times longer with sp4.  I have
> updated the stats for all the tables in the query.

> sp_lock:
> 64 8 0 0 DB                 S GRANT
> 64 8 1332199796 0 TAB                 Sch-S GRANT
> 64 8 435532635 1 PAG 5:3926175       IS GRANT
> 64 8 1316199739 0 TAB                 Sch-S GRANT
> 64 8 1145823194 1 PAG 5:3999638       S GRANT
> 64 8 1284199625 0 TAB                 IS GRANT
> 64 8 435532635 1 KEY (7b001c56dc00)  S GRANT
> 64 8 1333631844 0 TAB                 IS GRANT
> 64 8 1145823194 0 TAB                 IS GRANT
> 64 8 435532635 0 TAB                 IS GRANT
> 64 8 784721848 0 TAB                 IS GRANT
> 64 8 1236199454 0 TAB                 Sch-S GRANT
> 64 8 435532635 2 PAG 4:3195035       IS GRANT
> 64 8 1076198884 0 TAB                 Sch-S GRANT
> 64 8 1284199625 1 PAG 1:4998275       IS GRANT
> 64 8 1333631844 1 PAG 4:3107397       IS GRANT

> sysprocesses
> 64 4232 64 0x0422 0 PAGEIOLATCH_SH 8:1:5156833 8 0 13219878 1160381 0
> 2005-05-14
> 11:53:46.567 2005-05-14 12:04:11.867 0 0 sleeping
> 0x2B82AF0AE9CA284BB2C9C1DC1A71D94A00000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000
> KAGUYA-Cube

>                                      Microsoft SQL Server Analysis
> Services

>           2104    SELECT

> 000D601CAB48 TCP/IP      analysis

> 0x0000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000
> 0x010008001012822AC080EDB40000000000000000 76 -1

> Appreciate your help.

> -- J
> "Adrian Zajkeskovic" wrote:

>> If you haven't done it already, update statistics with full scan or run
>> dbcc
>> dbreindex. Then reproduce the problem again and post the output of
>> sp_lock
>> and select * from sysprocesses for that spid.

>> Adrian

>> "Jonathan Levine" <my...@nospam.nospam> wrote in message
>> news:A9F5109B-6C54-424B-9D03-A9B84E01B7F8@microsoft.com...
>> > Sorry for premature posting.  Here's what I meant to ask:

>> > I've noticed that several heavy queries that worked fine in SP3a now
>> > have
>> > unusual behavior.  The queries report that they are terminated as a
>> > deadlock
>> > victim; however, there aren't any DML operations running on the
>> > database
>> > at
>> > the time.  When I look at the status with sp_who2, I see that the query
>> > appears to be blocked by itself:

>> > SPID         Status      Login              BlkBy     Command
>> > 71   sleeping   reporting ... 71     ... SELECT

>> > sp_lock reports that the process has an exclusive lock on an extent in
>> > tempdb, but I don't see any other X locks around.

>> > Has anyone else seen anything like this?

>> > Regards,

>> > Jonathan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.