使用的TransactionScope和MS DTC时常见的问题问题、TransactionScope、MS、DTC

2023-09-02 10:44:58 作者:百思不得骑姐

我刚开始使用的TransactionScope的工作,我发现总有我碰上了采取永远调试意想不到的事情。

I am just starting to work with using TransactionScope, I find that there are always unexpected things I run into that take forever to debug.

我想,有这些的综合清单将是巨大的那些奇怪的错误的情况下,再加以扩大我们奇怪的知识平台。

I figure that having a consolidated list of these would be great for those "weird error" circumstances, plus to expand our knowledge of oddness in the platform.

一些背景如何,我将使用事务范围:

Some context on how I am going to be using transaction scopes:

在Web应用程序 在多个Web服务器,应用服务器和SQL服务器 交易将主要是数据库事务,但有些人会被提升到写入MSMQ。

推荐答案

2的事情了我的头顶部:

2 things off the top of my head:

当你在同一范围内使用一个以上的连接对象在交易将被提升,即使连接具有相同的ConnectionString(这是固定在SQL 2008)。详情请阅读this螺纹和 dbconnectionscope 将解决这个问题在SQL 2005 在MSDTC实例需要能够看到对方,需要有自己的安全设置正确 http://support.microsoft.com/kb/899191 (允许入站和出站,不需要相互验证通常是最安全的赌注)。使用DTCPing解决DTC实例之间的连接问题如下解释: http://support.microsoft.com/kb/ 306843 transactions will be elevated when you use more than one connection object in the same scope, even if the connections have the same connectionstring (this is fixed in sql 2008). Read more in this thread and dbconnectionscope will solve that problem on sql 2005 msdtc instances need to be able to see each other and need to have their security set up correctly http://support.microsoft.com/kb/899191 (allow inbound and outbound, do not require mutual authentication is usually the safest bet). Use DTCPing to troubleshoot connection issues between dtc instances as explained here: http://support.microsoft.com/kb/306843

您想交易是轻量级尽可能,DTC引入大量的开销。还希望事务是尽可能地短,因此仅在该应用程序的服务器和不是Web服务器上介绍它们。使酒花在应用服务器和数据库尽可能小和之间的网络尽可能快地,在比应用服务器和分贝之间不同的连接发送的网络和应用服务器之间的网络流量,并且使最后一个尖叫快,可笑的短连接。

You want transactions to be lightweight as much as possible, dtc introduces a lot of overhead. You also want transactions to be as short as possible, so introduce them only on the application servers and not on the web server. Make the hop over the network between the application servers and the database as small as possible and as fast as possible, send network traffic between web and app servers over a different connection than between app servers and db, and make the last one a screaming fast, ridiculously short connection.

如果您有多个应用程序服务器,你可以考虑在服务器上有MSDTC运行的单个实例(例如,在数据库或应用程序服务器中的一个),并远程使用每一个这样所有的应用程序服务器,而不是运行他们拥有,但我不知道是什么额外的好处这个了。

If you have multiple application servers, you could consider having a single instance of msdtc running on a server (e.g. on the database or on one of the app servers) and use this remotely from all application servers instead of each one running their own, but I don't know what additional benefits this has.