in-doubt xact resolution 服务器配置选项in-doubt xact resolution Server Configuration Option

适用对象:是SQL Server 否Azure SQL 数据库 否Azure Synapse Analytics (SQL DW) 否并行数据仓库APPLIES TO: yesSQL Server noAzure SQL Database noAzure Synapse Analytics (SQL DW) noParallel Data Warehouse

使用 in-doubt xact resolution 选项可以控制 MicrosoftMicrosoft 分布式事务处理协调器 (MS DTC) 无法解决的默认事务结果。Use the in-doubt xact resolution option to control the default outcome of transactions that the MicrosoftMicrosoft Distributed Transaction Coordinator (MS DTC) is unable to resolve. 事务无法解决可能与 MS DTC 停止工作或恢复时的未知事务结果有关。Inability to resolve transactions may be related to the MS DTC down time or an unknown transaction outcome at the time of recovery.

下表列出了解决有疑问的事务可能出现的结果值。The following table lists the possible outcome values for resolving an in-doubt transaction.

结果值Outcome value 描述Description
00 没有假设。No presumption. 如果 MS DTC 无法解决任何有疑问的事务,恢复就会失败。Recovery fails if MS DTC cannot resolve any in-doubt transactions.
11 假设提交。Presume commit. 假设已提交任何 MS DTC 有疑问的事务。Any MS DTC in-doubt transactions are presumed to have committed.
22 假设中止。Presume abort. 假设已中止任何 MS DTC 有疑问的事务。Any MS DTC in-doubt transactions are presumed to have aborted.

若要尽可能减少扩展的停止工作时间,管理员可以选择将此选项配置为假设提交或假设中止,如以下示例所示。To minimize the possibility of extended down time, an administrator might choose to configure this option either to presume commit or presume abort, as shown in the following example.

sp_configure 'show advanced options', 1  
GO  
RECONFIGURE  
GO  
sp_configure 'in-doubt xact resolution', 2 -- presume abort  
GO  
RECONFIGURE  
GO  
sp_configure 'show advanced options', 0  
GO  
RECONFIGURE  
GO  
  

另外,管理员也可能希望保留默认值(没有假设)并允许恢复失败,以便了解 DTC 故障,如以下示例所示。Alternatively, the administrator might want to leave the default (no presumption) and allow recovery to fail in order to be made aware of a DTC failure, as shown in the following example.

sp_configure 'show advanced options', 1  
GO  
RECONFIGURE  
GO  
sp_configure 'in-doubt xact resolution', 1 -- presume commit  
GO  
reconfigure  
GO  
ALTER DATABASE pubs SET ONLINE -- run recovery again  
GO  
sp_configure 'in-doubt xact resolution', 0 -- back to no assumptions  
GO  
sp_configure 'show advanced options', 0  
GO  
RECONFIGURE  
GO  
  

in-doubt xact resolution 选项是一个高级选项。The in-doubt xact resolution option is an advanced option. 如果使用 sp_configure 系统存储过程来更改该设置,则仅当 show advanced options 设置为 1 时才可以更改 in-doubt xact resolutionIf you are using the sp_configure system stored procedure to change the setting, you can change in-doubt xact resolution only when show advanced options is set to 1. 该设置将立即生效,无需重新启动服务器。The setting takes effect immediately without a server restart.

备注

在任何分布式事务所涉及的所有 MicrosoftMicrosoftSQL ServerSQL Server 实例中,使此选项的配置始终保持一致,有助于避免数据的不一致。Consistent configuration of this option across all MicrosoftMicrosoftSQL ServerSQL Server instances involved in any distributed transactions will help avoid data inconsistencies.

另请参阅See Also

RECONFIGURE (Transact-SQL) RECONFIGURE (Transact-SQL)
服务器配置选项 (SQL Server) Server Configuration Options (SQL Server)
sp_configure (Transact-SQL)sp_configure (Transact-SQL)