Windows 上的 MSSQL: 復原資料庫時發生錯誤。無法連線到 MSDTC 確定交易的完成狀態

Microsoft.SQLServer.Windows.EventRule.DBEngine.Error_recovering_database_._Could_not_connect_to_MSDTC_to_check_the_completion_status_of_transaction_1_5_Rule (Rule)

使用 MS DTC 管理跨多台伺服器的分散式交易,且發生連接中斷時,分散式交易將處於不明或「不確定」的狀態。中斷的常見原因為

Knowledge Base article:

摘要

使用 MS DTC 管理跨多台伺服器的分散式交易,且發生連接中斷時,分散式交易將處於不明或「不確定」的狀態。中斷的常見原因為

上停止其他涉及的服務。連接中斷後,MS DTC 會讓該階段為進行中的所有交易,處於不一致的狀態。「不確定」交易會導致這些徵兆是因為 SQL Server 無法判定是要認可或是要復原交易,同時 SQL Server 需要 MS DTC 告訴它如何處理。

解決方式

有多種不同的方法可用於解決不一致的分散式交易問題::

若要使用 MS DTC 管理主控台::

.在 [執行] 對話方塊中輸入 "mmc.exe" (不帶引號),以開啟 Microsoft Management Console (MMC)

.在 MMC 的 [主控台] 功能表上,按一下 [新增/移除嵌入式管理單元]

.在 [新增/移除嵌入式管理單元] 對話方塊中,按一下 [新增]

.在 [新增獨立嵌入式管理單元] 對話方塊中,按一下 [元件服務],然後按一下 [新增] 以新增嵌入式管理單元。

.按一下 [關閉]

.在 [新增/移除嵌入式管理單元] 對話方塊中,按一下 [確定]

.在 [元件服務] 下的主控台根目錄中,展開 [元件服務],指向 [電腦],指向 [我的電腦],然後按一下 [分散式交易協調器]

.選取 [交易清單]。您將在詳細資料窗格中看到交易。在該交易上按一下滑鼠右鍵,然後按一下 [解決]。您有三個選項:[認可]、[中止] 或 [略過]。從中選擇適合您情況的選項

可覆寫的參數

名稱

描述

預設值

已啟用

啟用或停用該工作流程。

間隔 (秒)

每次重複執行工作流程之間的時間間隔 (秒)。

300

優先順序

定義警示優先順序。

1

嚴重性

定義警示嚴重性。

1

同步處理時間

同步處理時間

 

逾時 (秒)

指定工作流程失敗多少次後關閉並標示為失敗。

200

資料庫連線的逾時 (秒)

若工作流程無法在指定的期限之內存取資料庫,將會失敗並登錄一則事件。

15

Element properties:

TargetMicrosoft.SQLServer.Windows.DBEngine
CategoryEventCollection
EnabledTrue
Alert GenerateTrue
Alert SeverityWarning
Alert PriorityNormal
RemotableTrue
Alert Message
Windows 上的 MSSQL: 復原資料庫時發生錯誤。無法連線到 MSDTC 確定交易的完成狀態
{0}
CommentMom2017ID='{6B1C776D-E075-4F73-B9C0-66CEF9024905}';MOM2017GroupID={467ECC75-C5DA-42BD-955C-A73BBB51AF74}

Member Modules:

ID Module Type TypeId RunAs 
_F6DA1507_12AF_11D3_AB21_00A0C98620CE_ DataSource Microsoft.SQLServer.Windows.DataSource.EventCollectionFiltered Default
GenerateAlert WriteAction System.Health.GenerateAlert Default

Source Code:

<Rule ID="Microsoft.SQLServer.Windows.EventRule.DBEngine.Error_recovering_database_._Could_not_connect_to_MSDTC_to_check_the_completion_status_of_transaction_1_5_Rule" Target="SqlDiscW!Microsoft.SQLServer.Windows.DBEngine" Enabled="true" ConfirmDelivery="true" Remotable="true" Comment="Mom2017ID='{6B1C776D-E075-4F73-B9C0-66CEF9024905}';MOM2017GroupID={467ECC75-C5DA-42BD-955C-A73BBB51AF74}">
<Category>EventCollection</Category>
<DataSources>
<DataSource ID="_F6DA1507_12AF_11D3_AB21_00A0C98620CE_" Comment="{F6DA1507-12AF-11D3-AB21-00A0C98620CE}" TypeID="Microsoft.SQLServer.Windows.DataSource.EventCollectionFiltered">
<MachineName>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/MachineName$</MachineName>
<InstanceName>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/InstanceName$</InstanceName>
<ConnectionString>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/ConnectionString$</ConnectionString>
<MonitoringType>$Target/Property[Type="SqlDiscW!Microsoft.SQLServer.Windows.DBEngine"]/MonitoringType$</MonitoringType>
<SqlTimeoutSeconds>15</SqlTimeoutSeconds>
<TimeoutSeconds>200</TimeoutSeconds>
<IntervalSeconds>300</IntervalSeconds>
<SyncTime/>
<EventDisplayNumber>3437</EventDisplayNumber>
</DataSource>
</DataSources>
<WriteActions>
<WriteAction ID="GenerateAlert" TypeID="Health!System.Health.GenerateAlert">
<Priority>1</Priority>
<Severity>1</Severity>
<AlertMessageId>$MPElement[Name="Microsoft.SQLServer.Windows.EventRule.DBEngine.Error_recovering_database_._Could_not_connect_to_MSDTC_to_check_the_completion_status_of_transaction_1_5_Rule.AlertMessage"]$</AlertMessageId>
<AlertParameters>
<AlertParameter1>Event ID: $Data/Property[@Name='EventID']$. $Data/Property[@Name='Message']$</AlertParameter1>
</AlertParameters>
<Suppression>
<SuppressionValue/>
</Suppression>
</WriteAction>
</WriteActions>
</Rule>