Thursday, 21 June 2012

Negative SPIDs in SQL Server


While investigating SQL performance issues,you might see SPIDs with negative number blocking other processes.

SPID -2  -> orphaned distributed transaction SPID

The SPID may still be holding on resources ( table, page or row locks), and blocking other SPIDs which want to access that database object. But  KILL command can’t handle SPIDs with a value of less than 1.

Kill -2
Msg 6101, Level 16, State 1, Line 1
Process ID -2 is not a valid process ID. Choose a number between 1 and 2048

To fix it:

select req_transactionUOW
from master..syslockinfo
where req_spid = -2

This will return a 32 digit UOW number eg: 'EDF10728-0156-1112-C501-AG48D72D2310'

KILL 'EDF10728-0156-1112-C501-AG48D72D2310'

Now if you check sp_who/sp_who2 all the offending SPID would have disappeared.

For negative SPIDS (-3 and -4)..

Please refer..

http://www.sqlskills.com/BLOGS/PAUL/post/Disaster-recovery-101-dealing-with-negative-SPIDS-%28-2-and-3%29.aspx


No comments:

Post a Comment