正在阻塞的会话

Microsoft.SQLServer.2012.DBEngine.BlockedSPIDsMonitor (UnitMonitor)

监视 SQL 实例的阻塞的会话。

Knowledge Base article:

摘要

正在阻塞的会话监视器检测是否存在正在阻塞的情况。

当一个会话持有一个特定资源的锁而另一个会话尝试获取同一资源上的相冲突锁类型时,则会出现阻塞。对于采用基于锁的并发机制的任何关系数据库管理系统(RDBMS)而言,阻塞是不可避免的。但是,阻塞过多可能导致性能问题。

原因

当锁定和阻塞增长到严重影响系统性能时,通常是以下原因之一造成的:

解决方法

或者,如果无需考虑数据库的阻塞的会话:

另请参阅:“ INF: Understanding and resolving SQL Server blocking problems(INF: 理解和解决 SQL Server 阻塞问题)”

可替代参数

名称

说明

默认值

警报优先级

定义警报优先级。

警报严重性

定义警报严重性。

错误

已启用

启用或禁用工作流。

生成警报

定义工作流是否生成警报。

间隔(秒)

运行工作流的重复间隔时间(秒)。

300

已阻塞的会话数

已阻塞的会话数。

1

同步时间

使用 24 小时格式指定的同步时间。可以忽略。

 

超时(秒)

指定允许工作流在被关闭并标记为失败之前运行的时间。

300

等待时间(分钟)

在考虑对进程进行已阻塞 SPID 分析之前的进程最小执行持续时间。

1

Element properties:

TargetMicrosoft.SQLServer.2012.DBEngine
Parent MonitorSystem.Health.PerformanceState
CategoryPerformanceHealth
EnabledFalse
Alert GenerateTrue
Alert SeverityError
Alert PriorityHigh
Alert Auto ResolveTrue
Monitor TypeMicrosoft.SQLServer.2012.DBEngine.BlockedSPIDs
RemotableTrue
AccessibilityPublic
Alert Message
已阻塞的会话
计算机“{2}”上 SQL 实例“{1}”中的会话 {0} 已阻塞。有关详细信息,请参阅“警报上下文”选项卡。
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.SQLServer.2012.DBEngine.BlockedSPIDsMonitor" Accessibility="Public" Enabled="false" Target="SQL2012Core!Microsoft.SQLServer.2012.DBEngine" ParentMonitorID="SystemHealth!System.Health.PerformanceState" Remotable="true" Priority="Normal" TypeID="Microsoft.SQLServer.2012.DBEngine.BlockedSPIDs" ConfirmDelivery="false">
<Category>PerformanceHealth</Category>
<AlertSettings AlertMessage="Microsoft.SQLServer.2012.DBEngine.BlockedSPIDsMonitor.AlertMessage">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>High</AlertPriority>
<AlertSeverity>Error</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Data/Context/Property[@Name='BlockedSPIDList']$</AlertParameter1>
<AlertParameter2>$Target/Property[Type="SQL!Microsoft.SQLServer.ServerRole"]/InstanceName$</AlertParameter2>
<AlertParameter3>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</AlertParameter3>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Blocked" MonitorTypeStateID="Blocked" HealthState="Error"/>
<OperationalState ID="NotBlocked" MonitorTypeStateID="NotBlocked" HealthState="Success"/>
</OperationalStates>
<Configuration>
<ConnectionString>$Target/Property[Type="SQL!Microsoft.SQLServer.DBEngine"]/ConnectionString$</ConnectionString>
<IntervalSeconds>300</IntervalSeconds>
<SyncTime/>
<WaitMinutes>1</WaitMinutes>
<NumberBlockedSPIDs>1</NumberBlockedSPIDs>
<TimeoutSeconds>300</TimeoutSeconds>
<InstanceName>$Target/Property[Type="SQL!Microsoft.SQLServer.ServerRole"]/InstanceName$</InstanceName>
<ComputerName>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</ComputerName>
</Configuration>
</UnitMonitor>