封鎖工作階段

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

監視 SQL 執行個體封鎖的工作階段。

Knowledge Base article:

摘要

封鎖工作階段監視器會偵測有沒有封鎖的情況存在。

如果有一個工作階段鎖住了特定的資源,而另一個工作階段嘗試要在同一項資源上取得衝突的鎖定類型,就會發生封鎖。封鎖是任何具備鎖定並行處理功能的關聯式資料庫管理系統 (RDBMS) 上,無法避免的一項特性。但是太多的封鎖可能會造成效能方面的問題。

原因

如果鎖定和封鎖增加到會對系統效能造成明顯的影響,通常是下列其中一個原因所造成:

解決方式

或者,如果不需要為資料庫考量被封鎖的工作階段數目:

另請參閱: INF: 瞭解並解決 SQL Server 7.0 封鎖問題

可覆寫的參數

名稱

描述

預設值

警示優先程式

定義警示優先順序。

警示嚴重性

定義警示嚴重性。

錯誤

已啟用

啟用或停用該工作流程。

產生警示

定義工作流程是否會產生警示。

間隔 (秒)

執行工作流程的週期性時間間隔 (秒)。

300

受封鎖的工作階段數目

封鎖的工作階段數目。

1

同步處理時間

使用 24 小時制指定的同步處理時間。將會忽略。

 

逾時 (秒)

指定允許工作流程在關閉且標示為失敗之前執行的時間。

300

等候時間 (分鐘)

考慮將程序用於進行「封鎖 SPID」分析之前的程序執行時間下限。

1

Element properties:

TargetMicrosoft.SQLServer.2008.DBEngine
Parent MonitorSystem.Health.PerformanceState
CategoryPerformanceHealth
EnabledFalse
Alert GenerateTrue
Alert SeverityError
Alert PriorityHigh
Alert Auto ResolveTrue
Monitor TypeMicrosoft.SQLServer.2008.DBEngine.BlockedSPIDs
RemotableTrue
AccessibilityPublic
Alert Message
已封鎖工作階段
已封鎖電腦 "{2}" 上 SQL 執行個體 "{1}" 中的工作階段 {0}。請參閱 [警示內容] 索引標籤,以取得詳細資料。
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.SQLServer.2008.DBEngine.BlockedSPIDsMonitor" Accessibility="Public" Enabled="false" Target="SQL2008Core!Microsoft.SQLServer.2008.DBEngine" ParentMonitorID="SystemHealth!System.Health.PerformanceState" Remotable="true" Priority="Normal" TypeID="Microsoft.SQLServer.2008.DBEngine.BlockedSPIDs" ConfirmDelivery="false">
<Category>PerformanceHealth</Category>
<AlertSettings AlertMessage="Microsoft.SQLServer.2008.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>