在SSIS Server上,发现一个Package Job运行异常,该Package处于僵死状态。从 Job Activity Monitor中看到该Job一直处于运行状态,但是,DW中没有执行任何Query 操作。从Operation的Event Message看到 :Package_Path 是 \Package.EventHandlers[OnPreValidate]\Stop running Jobs
事件处理程序 OnPreValidate 的官方定义是:
OnPreValidate:The event handler for the OnPreValidate event. This event is raised by an executable when its validation starts.
正常运行的Package,其Package_Path 表示的是 Package 中 Executable的路径,而该Package在开始运行时就进入到EventHandlers中去执行OnPreValidate 事件处理程序,莫非在Event Handlers中定义了OnPreValidate 事件处理程序?
打开SSIS Project,查看Package的Event Handlers Tab,真的存在 Stop running Jobs Executable。
在Stop running jobs 这个Task中,调用 dbo.sp_stop_job 指示SQL Server Agent停掉某些Job。从Package调用的优先约束上,看到这些被stop的Package都在当前Package执行之前就已经结束运行,所以,这个Stop running jobs Task 是画蛇添足。由于任何一个Task或Container执行前,都要调用OnPreValidate 事件处理程序,对Package的执行性能有副作用。
我遇到的情况,从执行记录上查看到该Package并没有将所有的 Executable 执行完成,但是该package却异常的提前终止,并且执行结果是Success。
Appendix:
引用《sp_stop_job》
Instructs SQL Server Agent to stop the execution of a job.
sp_stop_job [@job_name =] 'job_name' | [@job_id =] job_id | [@originating_server =] 'master_server' | [@server_name =] 'target_server'
When SQL Server Agent receives the stop notification, it waits for the job step that is currently running to finish before it processes the cancel request. Some long-running Transact-SQL statements such as BACKUP, RESTORE, and some DBCC commands can take a long time to finish. When these are running, it may take a while before the job is canceled. Stopping a job causes a "Job Canceled" entry to be recorded in the job history.
参考文档: