views:

173

answers:

1

We had a problem today on our dev server where a process locked one table, stopping all other queries on that table to work. When running sql_who2 the blkBy columns value was -2, but the -2 was not in the process list.

When running DBCC INPUTBUFFER (-2) I got the exception Invalid SPID -2 specified.

When running beta_lockinfo I see all the tables and indexes it locks, but all other information is null, except that the ownertype was Transaction.

When restarting the webapp(did a change in web.config) the lock dissapered and the same did all the traces of the -2 SPID

My question is why is the SPID a negative value and why can I not get any info about it?

+2  A: 

A SPID of -2 represents that your process was blocked by an orphaned distributed transaction.

You can use KILL 'GUID-OF-THE-UOW' to terminate orphaned distributed transactions, or any other distributed transaction. To do this you'll need to get the GUID of the Unit of Work (UOW) from sys.dm_tran_locks.request_owner_guid.

SELECT
    [tl].[request_owner_guid]
FROM
    sys.dm_tran_locks tl
WHERE
    [tl].[request_session_id] = -2

-2 is just an artificial association. The session ID of -2 just makes it easier to identify orphaned transactions by querying the session ID column in the dynamic management views.

The Lazy DBA
Thx! Do you know how if it ispossible to find the source of the distributed transaction? Any inforamtion at all?
Atle
You should be able to open the Microsoft Distributed Transaction Coordinator MMC snap-in by typing 'dcomcnfg' at the Start > Run... dialog.Under the local DTC node, look for transactions that have been marked in-doubt. Likely this transaction came from a remote server.
The Lazy DBA