SSISDB8:使用SSISDB记录的消息Troubleshoot packages

时间:2023-01-22 21:41:53

SSISDB 系列随笔汇总:

Package的每一次执行(Execution),集成服务引擎都会在SSISDB中创建唯一的操作实例(Operation) 和 执行实例(Execution),实例都有唯一的ID进行标识。跟SSIS工程操作相关的是操作实例,跟Package的运行相关的是执行实例。Package的每次执行都会生成一个唯一的ExecutionID,并记录执行实例运行的结果和状态。在每个Execution Instance中,Package都会执行Task或Container,每一个Task或Container都是一个Executable,SSISDB会记录每个Executable执行的状态。

一,创建转存文件

转存文件(dump file)主要用于Package的开发阶段,用于对Package进行测试和故障排除。转存文件默认存储在ErrorDumps文件夹下:C:\Program Files\Microsoft SQL Server\110\Shared\ErrorDumps,扩展名是.tmp和 .mdmp,前者是以文本格式存储,该文件会记录Package执行实例的最近的消息,后者是而二进制文件。

创建转存文件,有两种方式:

  • 第一种方式:使用特殊的执行参数,配置执行实例,当Package在运行过程中出现错误,或者错误事件被触发时,集成服务引起自动创建转存文件。
  • 第二种方式:在Package正在运行(running)时,调用 catalog.create_execution_dump  存储,暂停当前的执行实例,创建转存文件。

1,为正在运行的Package创建转存文件

调用存储过程:catalog.create_execution_dump,暂停正在执行的Package,创建转存文件。一旦成功创建转存文件,那么package将会终止运行。

exec catalog.create_execution_dump [ @execution_id = ] execution_id

2,在执行Package之前,设置执行参数

通过设置Package执行实例的配置参数:DUMP_ON_ERROR,在Package运行出现错误时,自动创建转存文件。

exec catalog.set_execution_parameter_value
@execution_id = @package_execution_id
, @object_type = 50
, @parameter_name = 'DUMP_ON_ERROR'
, @parameter_value = 1

二,查询执行实例

执行实例都会对应一个操作实例,执行实例是Package的一次执行,该Package可能会调用其他Package。每个Package都会执行其包含的可执行组件(Executable),处理数据;集成服务引擎会记录Package和可执行组件的状态。

1,查询执行实例

select e.execution_id,
e.folder_name,
e.object_type,
obt.object_type_descr,
e.project_name,
e.package_name,
opt.operation_type_descr,
e.created_time,
ops.operation_status_descr as execution_status,
e.caller_name,
e.start_time,
e.end_time
from catalog.executions e
inner join helper.OperationType opt
on e.operation_type=opt.operation_type
inner join helper.ObjectType obt
on e.object_type=obt.object_type
inner join helper.OperationStatus ops
on e.status=ops.operation_status
order by e.start_time desc

2,查询Executable

select e.executable_id,
e.package_name,
e.package_path,
e.executable_name,
--e.executable_guid,
er.execution_result_descr,
es.execution_duration/1000/60 as execution_duration_m,
cast(es.start_time as datetime) as start_time,
cast(es.end_time as datetime) as end_time,
es.execution_value
from catalog.executables e
inner join catalog.executable_statistics es
on e.executable_id=es.executable_id
and e.execution_id=es.execution_id
inner join helper.ExecutionResult er
on es.execution_result=er.execution_result
where e.execution_id=23537
order by es.end_time desc

三,查看Execution的资源消耗

如果一个 执行实例正在运行,处于running 状态,可以通过函数 catalog.dm_execution_performance_counters(@execution_id) 查看资源利用情况,该函数返回12个performance counter,统计该running execution自开始执行到现在为止的信息。

select e.execution_id,
e.folder_name,
e.project_name,
e.package_name,
e.start_time,
epc.counter_name,
epc.counter_value
from catalog.executions e
cross apply catalog.dm_execution_performance_counters(e.execution_id) as epc
where e.status=2 --running
order by e.execution_id,
epc.counter_name

四,在package执行错误时,查看失败的Executable

select e.folder_name,
e.project_name,
opt.operation_type_descr as operation,
obt.object_type_descr as object_type,
ops.operation_status_descr as operation_status,
et.package_name,
et.package_path as executable_path,--relative path
--es.execution_path as executable_full_path,
et.executable_name,
cast(es.execution_duration/1000/60.0 as decimal(10,1))as duration_m,
er.execution_result_descr as execution_result,
es.start_time
--,es.end_time
from catalog.executions e
inner join helper.OperationType opt
on e.operation_type=opt.operation_type
inner join helper.ObjectType obt
on e.object_type=obt.object_type
inner join helper.OperationStatus ops
on e.status=ops.operation_status
inner join catalog.executables et
on e.execution_id=et.execution_id
inner join catalog.executable_statistics es
on et.executable_id=es.executable_id
and et.execution_id=es.execution_id
inner join helper.ExecutionResult er
on es.execution_result=er.execution_result
where e.execution_id=23537 --Specified ExecutionID
and es.execution_result=1 -- 1 (Failure)
--and et.package_name=N'PackageName.dtsx'
order by et.package_name
,es.start_time desc;

附,helper 辅助表

关于helper 辅助表,请参考《SSISDB2:Operation》的“Appendix”

参考文档:

Views (Integration Services Catalog)

catalog.set_execution_parameter_value (SSISDB Database)

SSIS Catalog