我正在使用 LINQ to SQL 和支持分布式事务的第三方 SDK。当我意识到挂起的更新将同时更新 SQL 记录和第三方 SDK 中的记录时,我正在创建一个超时为 0(可能是无限)的 TransactionScope(尽管我也尝试了 12 小时作为时间跨度参数)。然后我在环境事务(由 transactionscope 创建)上使用 GetDtcTransaction 来获取 DTC 事务以链接到第三方 SDK。事情在大约 10 分钟内运行良好,但 10 分钟后,事务消失并发生错误。我如何确定交易消失的原因。我怀疑这是一个超时,因为它经常在 10 分钟后发生,即使此时已经完成了略有不同程度的工作。但是我'
我尝试使用 SQL 探查器跟踪以下事件:
- 所有错误和警告事件
- 除“审计架构对象”事件外的所有安全事件
- 除 SQLTransaction 和 TransactionLog 事件外的所有事务事件
我在错误发生时得到的只是这些事件:
<Event id="19" name="DTCTransaction">
<Column id="3" name="DatabaseID">1</Column>
<Column id="11" name="LoginName">sa</Column>
<Column id="35" name="DatabaseName">master</Column>
<Column id="51" name="EventSequence">167065</Column>
<Column id="12" name="SPID">10</Column>
<Column id="60" name="IsSystem">1</Column>
<Column id="1" name="TextData">{D662BBC4-21EC-436D-991C-DCB061A34782}</Column>
<Column id="21" name="EventSubClass">16</Column>
<Column id="25" name="IntegerData">0</Column>
<Column id="41" name="LoginSid">01</Column>
<Column id="49" name="RequestID">0</Column>
<Column id="2" name="BinaryData">C4BB62D6EC216D43991CDCB061A34782</Column>
<Column id="14" name="StartTime">2009-11-11T13:55:32.82-06:00</Column>
<Column id="26" name="ServerName">.</Column>
<Column id="50" name="XactSequence">0</Column>
</Event>
<Event id="33" name="Exception">
<Column id="3" name="DatabaseID">9</Column>
<Column id="11" name="LoginName">sa</Column>
<Column id="31" name="Error">1222</Column>
<Column id="35" name="DatabaseName">ACS</Column>
<Column id="51" name="EventSequence">167066</Column>
<Column id="12" name="SPID">19</Column>
<Column id="20" name="Severity">16</Column>
<Column id="60" name="IsSystem">1</Column>
<Column id="1" name="TextData">Error: 1222, Severity: 16, State: 18</Column>
<Column id="41" name="LoginSid">01</Column>
<Column id="49" name="RequestID">0</Column>
<Column id="14" name="StartTime">2009-11-11T13:55:34.717-06:00</Column>
<Column id="26" name="ServerName">.</Column>
<Column id="30" name="State">18</Column>
<Column id="50" name="XactSequence">0</Column>
</Event>
<Event id="33" name="Exception">
<Column id="31" name="Error">8525</Column>
<Column id="8" name="HostName">MARTY755</Column>
<Column id="12" name="SPID">55</Column>
<Column id="20" name="Severity">16</Column>
<Column id="64" name="SessionLoginName">fse</Column>
<Column id="1" name="TextData">Error: 8525, Severity: 16, State: 1</Column>
<Column id="9" name="ClientProcessID">2516</Column>
<Column id="41" name="LoginSid">DB2744F54B5CDB4A8B9E5CA9C209A7AC</Column>
<Column id="49" name="RequestID">0</Column>
<Column id="10" name="ApplicationName">.Net SqlClient Data Provider</Column>
<Column id="14" name="StartTime">2009-11-11T13:55:37.54-06:00</Column>
<Column id="26" name="ServerName">.</Column>
<Column id="30" name="State">1</Column>
<Column id="50" name="XactSequence">236223201284</Column>
<Column id="3" name="DatabaseID">9</Column>
<Column id="11" name="LoginName">fse</Column>
<Column id="35" name="DatabaseName">ACS</Column>
<Column id="51" name="EventSequence">167067</Column>
</Event>
<Event id="162" name="User Error Message">
<Column id="31" name="Error">8525</Column>
<Column id="8" name="HostName">MARTY755</Column>
<Column id="12" name="SPID">55</Column>
<Column id="20" name="Severity">16</Column>
<Column id="64" name="SessionLoginName">fse</Column>
<Column id="1" name="TextData">Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.</Column>
<Column id="9" name="ClientProcessID">2516</Column>
<Column id="41" name="LoginSid">DB2744F54B5CDB4A8B9E5CA9C209A7AC</Column>
<Column id="49" name="RequestID">0</Column>
<Column id="10" name="ApplicationName">.Net SqlClient Data Provider</Column>
<Column id="14" name="StartTime">2009-11-11T13:55:37.54-06:00</Column>
<Column id="26" name="ServerName">.</Column>
<Column id="30" name="State">1</Column>
<Column id="50" name="XactSequence">236223201284</Column>
<Column id="3" name="DatabaseID">9</Column>
<Column id="11" name="LoginName">fse</Column>
<Column id="35" name="DatabaseName">ACS</Column>
<Column id="51" name="EventSequence">167068</Column>
</Event>
DTCTransaction 事件上的 EventSubClass 16 指示“事务正在中止”。