Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Hung spid question.

Author  Topic 

viperbyte
Posting Yak Master

132 Posts

Posted - 2012-12-14 : 13:25:16
Hello everyone, second week and still here, whew.
What's the effect, damage if any on having a couple of SPIDs hanging around? When I run this script:

SELECT LTRIM (st.[text]) AS [Command Text],[host_name], der.session_id AS [SPID],
der.[status], db_name(database_id) AS [Database Name],
ISNULL(der.wait_type, 'None') AS [Wait Type],
der.logical_reads, der.cpu_time, der.total_elapsed_time
FROM sys.dm_exec_requests AS der
INNER JOIN sys.dm_exec_connections AS dexc
ON der.session_id = dexc.session_id
INNER JOIN sys.dm_exec_sessions AS dexs
ON dexs.session_id = der.session_id
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS st
WHERE der.session_id >= 51
AND der.session_id <> @@spid -- eliminate this connection
ORDER BY der.[status]

I get these two rows of output:
Command Text host_name SPID status Database Name Wait Type logical_reads cpu_time total_elapsed_time
create procedure [sys].[sp_cdc_scan] xxxxx 52 suspended myDB WAITFOR 587108 22479 208296248
create procedure[sys].[sp_cdc_scan] xxxxx 53 suspended Document Management WAITFOR 704333 49655 208296247

Am I supposed to do something about this?

viperbyte
Posting Yak Master

132 Posts

Posted - 2012-12-14 : 13:27:08
I just read my post and see how tough it is to read the output. 52 and 53 are from the SPID column.
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2012-12-14 : 14:00:24
They look like they're running Change Data Capture procedures. I don't recommend killing them until you can investigate (check CDC config, is it running? should it be running? etc.) If you don't need CDC then it's better to simply turn it off rather than killing its SPIDs.
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2012-12-15 : 12:11:17
It is also useful to include the "blocking_session_id" column from the sys.dm_exec_requests - gives a quick guide on whether the request is being blocked

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page
   

- Advertisement -