gpt4 book ai didi

exception - 这些 MS DTC 异常是什么意思?

转载 作者:行者123 更新时间:2023-12-02 05:04:52 25 4
gpt4 key购买 nike

我编写了一个程序来演示多线程 DTC 超时的行为。我有几个异常(exception),似乎是随机的。所有这些都是简单的超时,还是其中一些指示更深层次的问题(连接池交互等)?

The Microsoft Distributed Transaction Coordinator (MS DTC) has cancelled the distributed transaction.

Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.

The transaction associated with the current connection has completed but has not been disposed. The transaction must be disposed before the connection can be used to execute SQL statements.

The operation is not valid for the state of the transaction.

ExecuteReader requires an open and available Connection. The connection's current state is closed.

这是代码的数据部分:

using (DemoDataDataContext dc1 = new DemoDataDataContext(Conn1))
using (DemoDataDataContext dc2 = new DemoDataDataContext(Conn2))
{
WriteMany(dc1, 100); //generate 100 records for insert
WriteMany(dc2, 100000); //generate 100,000 records for insert

Console.WriteLine("{0} : {1}", Name, " generated records for insert.");
using (TransactionScope ts = new TransactionScope())
{
dc1.SubmitChanges();
dc2.SubmitChanges();
ts.Complete();
}
}

最佳答案

所有这些异常都告诉我您有内存泄漏。对我来说,这些异常不仅仅是一些简单的超时,我认为你应该寻找更深层次的问题。

ts.Complete() 不保证事务的提交。这只是一种通知交易经理您的状态的方式。 http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.complete.aspx

您通知交易经理您的交易已完成而实际上并未完成,这是否有问题?

关于exception - 这些 MS DTC 异常是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13145802/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com