今天遇到了一个奇葩问题,业务运行了不到1分钟,就跑出来一个数据库错误,而且还是不定行的,错误内容是 无法获取错误消息(6107)(0) , 英文是 Unable to get error message(6107)(0) , 如果大家谁还遇到这个问题,那我帮你定位 100% 是分布式事务 超时所引
今天遇到了一个奇葩问题,业务运行了不到1分钟,就跑出来一个数据库错误,而且还是不定行的,错误内容是 无法获取错误消息(6107)(0) , 英文是 Unable to get error message(6107)(0) ,
如果大家谁还遇到这个问题,那我帮你定位 100% 是分布式事务 超时所引起的。一般在打开事务的地方需要设置超时时间
1 2 3 4 5 6 7 | using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(1, 0, 0)))
{
}
|
Nach dem Login kopieren
我的超时情况比较复杂,因为事务里面还有WCF 访问,所以WCF 的连接超时也会影响分布式事务,设置WCF的时间
1 2 3 4 5 6 7 8 9 10 11 12 | <binding name= "transactionalBinding" receiveTimeout= "00:30:00" sendTimeout= "00:30:00" >
<textMessageEncoding>
<readerQuotas maxArrayLength= "2147483647" maxStringContentLength= "2147483647" maxDepth= "64" />
</textMessageEncoding>
<transactionFlow transactionProtocol= "WSAtomicTransaction11" />
<httpsTransport manualAddressing= "false" maxBufferPoolSize= "524288"
maxReceivedMessageSize= "2147483647" allowCookies= "false" authenticationScheme= "Anonymous"
bypassProxyOnLocal= "false" hostNameComparisonMode= "StrongWildcard"
keepAliveEnabled= "true" maxBufferSize= "2147483647" proxyAuthenticationScheme= "Anonymous"
realm= "" transferMode= "Buffered" unsafeConnectionNtlmAuthentication= "false"
useDefaultWebProxy= "true" />
</binding>
|
Nach dem Login kopieren
另外还要设置Web.Config 对于这个应用的分布式事务超时
1 2 3 | <system.transactions>
<defaultSettings timeout= "00:30:00" />
</system.transactions>
|
Nach dem Login kopieren
最后一点,如果还是在10分钟内就断掉了,就要设置Machine.Config 了
C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG
1 2 3 4 5 | <configuration>
<system.transactions>
<machineSettings maxTimeout= "00:30:00" />
</system.transactions>
</configuration>
|
Nach dem Login kopieren