If you are frequently encountering the I/O errors like below , and to analyze when exactly these are happening you need
to export all the io errors into a table , so that you can sort based on date and time to see the trends.
below script will export all the io errors from error log in sql server into a temp table #io_errors
output :
use tempdb
create table #IO_ERRORS(LogDate datetime,ProcessInfo varchar(30),text varchar(max))
declare @error_msg varchar(2000) = 'requests taking longer than 15 seconds to complete on
file'
insert into #IO_ERRORS EXEC master.dbo.xp_readerrorlog 0, 1,@error_msg , '', NULL, NULL, N'desc'
insert into #IO_ERRORS EXEC master.dbo.xp_readerrorlog 1, 1,
@error_msg ,
'', NULL, NULL, N'desc'
insert into #IO_ERRORS EXEC master.dbo.xp_readerrorlog 2, 1,
@error_msg ,
'', NULL, NULL, N'desc'
insert into #IO_ERRORS EXEC master.dbo.xp_readerrorlog 3, 1,
@error_msg ,
'', NULL, NULL, N'desc'
insert into #IO_ERRORS EXEC master.dbo.xp_readerrorlog 4, 1,
@error_msg ,
'', NULL, NULL, N'desc'
insert into #IO_ERRORS EXEC master.dbo.xp_readerrorlog 5, 1,
@error_msg ,
'', NULL, NULL, N'desc'
insert into #IO_ERRORS EXEC master.dbo.xp_readerrorlog 6, 1,
@error_msg ,
'', NULL, NULL, N'desc'
select LogDate,physical_name,
OCCURANCES= cast(SUBSTRING(TEXT,CHARINDEX('SQL Server has encountered ',TEXT)+27, CHARINDEX('occurrence(s) of I/O requests taking longer than ',TEXT)-CHARINDEX('SQL Server has encountered ',TEXT)-27) as int) --,CAST(logdate as DATE) as dt, DATEPART(HH,logdate ) as h ,DATEPART(MINUTE,logdate ) as minu from #IO_ERRORS a JOIN sys.master_files b on a.text like '%'+b.physical_name +'%' order by 3 desc |
No comments:
Post a Comment