링크드 프로시저의 timeout 발생시 SQL Agent Job 실패만들기
이런경우에는 찾기 어려울 것 같다.
작업의 로그를 모니터링 하는 수 밖에 없을 듯. 모리터링 쿼리는 아래와 같다.
SELECT JS.name AS JobName,
JH.step_name AS StepName,
JH.message AS StepMessage,
JH.run_duration AS StepDuration,
JH.run_date AS TS
FROM msdb.dbo.sysjobhistory JH
INNER JOIN msdb.dbo.sysjobs JS ON JS.job_id = JH.job_id
WHERE JH.message LIKE '%Query timeout expired%'
ORDER BY JH.run_date desc
GO
Forcing SQL Agent Jobs to Fail When Remote Procedures Timeout
By Chad Feghali, 2016/05/02
Introduction
Your SQL Agent Jobs may be silently failing if you are using Linked Servers to make remote procedure calls. On occasion these jobs will show a false success message in the job history like the following:
The step above actually failed since the remote procedure call timed out. This issue has existed in the SQL Server platform for several versions, including SQL 2016 RC3. It has been reported to Microsoft as early as 4/5/2008 in this issue report. The Linked Server Provider treats the Query timeout as a warning and does not raise an error. The issue report does recommend a workaround which can easily be overlooked without a full example. A full example is provided in this article.
Reproducing the Query Timeout
To reproduce this issue, we will establish a Linked Server and change the timeout from the default of 600 seconds to a few seconds.
1. Establish a Linked Server, we'll use localhost for simplicity.
EXEC master.dbo.sp_addlinkedserver @server = N'LOCALHOST', @srvproduct=N'SQL Server'
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'LOCALHOST',@useself=N'True',@locallogin=NULL,@rmtuser=NULL,@rmtpassword=NULL
EXEC master.dbo.sp_serveroption @server=N'LOCALHOST', @optname=N'rpc', @optvalue=N'true'
EXEC master.dbo.sp_serveroption @server=N'LOCALHOST', @optname=N'rpc out', @optvalue=N'true'
2. Next we'll adjust the timeout to a few seconds.
exec sp_configure'remote query timeout', 5
reconfigure
3. Now executing the following will simulate the query timeout.
DECLARE @returnCode int = 0
DECLARE @sql nvarchar(max) = 'WAITFOR DELAY ''00:00:06''; exec sp_who2'
EXEC @returnCode = [localhost].master.dbo.sp_executesql @sql
출처: <http://www.sqlservercentral.com/articles/SQL+Agent/140491/>
키워드 : 예약작업실패