Hi Experts, I am facing an issue after killing a spid which was actually hanged in a job, job was calling a stored procedure to read the sql server log and to send it via email.
here is the stored procedure code
ALTER procedure [Error_log_Reader] (@noofhours smallint) As Begin set nocount on Declare @errorlog table (logdate datetime, Processinfo varchar(15), errormessage varchar(max)) declare @starttime datetime declare @endtime datetime set @starttime = (select DATEADD(hh, -@noofhours, GETDATE())) set @endtime = (select GETDATE()) insert into @errorlog EXEC master.dbo.xp_readerrorlog 0, 1, 'Not',null , @starttime, @endtime insert into @errorlog EXEC master.dbo.xp_readerrorlog 0, 1, 'Error',null , @starttime, @endtime insert into @errorlog EXEC master.dbo.xp_readerrorlog 0, 1, 'Failed',null , @starttime, @endtime --- checking whethere any error is there in the log declare @errorcount smallint set @errorcount = 0 set @errorcount = (select COUNT(*) From @errorlog) ---- if there are errors, sending the email to dba if @errorcount > 0 begin --- then it will send me the email---- end End
It was working fine but today i got a CPU usage alert and i found that this job got hanged, i located the spid and killed but now it is in
waiting mode "lastwaittype" is msql_xp and the "waittime" is increasing in the sysprocesses view. Re-execution of kill process shows
transaction rollback in progress, estimated rollback completion 0%.
The instance is SQL SERVER 2005 SP1.
Please review the above code and if there is any bug in the code please identify. if there is any solution for getting rid of msql_xp wait without serive bouncing please share. Thanks