監視 SQL 執行個體的封鎖工作階段。附註: 預設會停用此監視器。必要時請使用覆寫加以啟用。
封鎖工作階段監視器會偵測有沒有封鎖的情況存在。
如果有一個工作階段在某一項特定資源上保持鎖定,而另一個工作階段嘗試要在同一項資源上取得衝突的鎖定類型,這種情況就會發生封鎖。封鎖是任何具備鎖定式並行處理功能的關聯式資料庫管理系統 (RDBMS) 所無法避免的特性。但是太多封鎖卻會造成效能的問題。
當鎖定及封鎖加大到對系統效能有相當大的影響時,通常是因為下列其中一個原因:
工作階段對一組資源保持鎖定,而且根本不釋放。通常是下列原因造成::
未回復已取消的查詢
被遺棄的交易
工作階段 (由 session_id 或 “SPID” 識別) 對一組資源長時間保持鎖定,然後才釋放。通常是下列原因造成::
長時間執行的交易
缺少適當的索引
鎖定提示使用不當
應用程式設計不良的其他相關問題
終止封鎖鏈結開頭的工作階段
縮短交易時間
建立適當的索引
使用鎖定提示。請參閱《SQL Server 線上叢書》
使用資料列版本控制架構的隔離等級
設定 SQL Server 設定 (記憶體設定、鎖定逾時等)
為此特定資料庫或所有資料庫變更監視的臨界值
或者,如果封鎖的工作階段與此資料庫無關::
停用此特定資料庫或所有資料庫的監視
名稱 | 描述 | 預設值 |
警示優先程式 | 定義警示優先順序。 | 高 |
警示嚴重性 | 定義警示嚴重性。 | 錯誤 |
已啟用 | 啟用或停用該工作流程。 | 否 |
產生警示 | 定義工作流程是否會產生警示。 | 是 |
間隔 (秒) | 執行工作流程的週期性時間間隔 (秒)。 | 300 |
受封鎖的工作階段數目 | 允許的受封鎖工作階段數目上限。 | 1 |
同步處理時間 | 使用 24 小時制指定的同步處理時間。將會忽略。 |
|
逾時 (秒) | 指定允許工作流程在關閉且標示為失敗之前執行的時間。 | 300 |
等候時間 (分鐘) | 考慮將程序用於進行「封鎖 SPID」分析之前的程序執行時間下限。 | 1 |
Target | Microsoft.SQLServer.2014.DBEngine | ||
Parent Monitor | System.Health.PerformanceState | ||
Category | PerformanceHealth | ||
Enabled | False | ||
Alert Generate | True | ||
Alert Severity | Error | ||
Alert Priority | High | ||
Alert Auto Resolve | True | ||
Monitor Type | Microsoft.SQLServer.2014.DBEngine.BlockedSPIDs | ||
Remotable | True | ||
Accessibility | Public | ||
Alert Message |
| ||
RunAs | Default |
<UnitMonitor ID="Microsoft.SQLServer.2014.DBEngine.BlockedSPIDsMonitor" Accessibility="Public" Enabled="false" Target="SQL2014Core!Microsoft.SQLServer.2014.DBEngine" ParentMonitorID="SystemHealth!System.Health.PerformanceState" Remotable="true" Priority="Normal" TypeID="Microsoft.SQLServer.2014.DBEngine.BlockedSPIDs" ConfirmDelivery="false">
<Category>PerformanceHealth</Category>
<AlertSettings AlertMessage="Microsoft.SQLServer.2014.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="SQL2014Core!Microsoft.SQLServer.2014.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="SQL2014Core!Microsoft.SQLServer.2014.DBEngine"]/ConnectionString$</ConnectionString>
<IntervalSeconds>300</IntervalSeconds>
<SyncTime/>
<WaitMinutes>1</WaitMinutes>
<NumberBlockedSPIDs>1</NumberBlockedSPIDs>
<TimeoutSeconds>300</TimeoutSeconds>
<InstanceName>$Target/Property[Type="SQL2014Core!Microsoft.SQLServer.2014.ServerRole"]/InstanceName$</InstanceName>
<ComputerName>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</ComputerName>
</Configuration>
</UnitMonitor>