如何调试DTC问题?
我对某些代码进行了单元测试,这些代码偶尔会抛出“事务已隐式或显式提交或中止”。例外。谷歌给了我很多精彩的点击,但我读过的似乎都不适用。
如果我在本地运行单元测试,则永远不会抛出异常。
如果我在构建服务器上手动运行它,则永远不会抛出异常。
事实上,唯一一次抛出异常的时间是在自动化构建和测试过程中的夜间,大约 80% 的时间都会抛出异常。
这几乎排除了有关该主题的所有 Google 结果,因为问题通常是由事务或防火墙中的数据库连接问题引起的。
任何事件日志(在运行测试的构建机器或开发数据库服务器上)中都没有任何事件表明存在问题。事实上,我看到的唯一相关事件消息是在数据库计算机上——“MSDTC:会话空闲超时,正在拆除会话”。事件在我运行测试后不久发生。
我不知道如何继续尝试找到这个问题。
有没有什么方法可以从事务状态的代码中生成详细信息(我使用 C# 和 .NET 3.5)?
有什么方法可以让事件日志为我提供更多信息来帮助追踪此问题吗?
如果这有助于找到合适的工具,则涉及的计算机是 Windows 2000 Server (db) 和 Windows Serer 2003(build)。
I have a unit test for some code that occasionally throws a "The transaction has already been implicitly or explicitly committed or aborted." exception. Google gives me lots of wonderful hits but none that I've read seem to apply.
If I run the unit test locally the exception is never thrown.
If I run it on the build server manually the exception is never thrown.
In fact, the only time the exception seems to get thrown is at night during an automated build and testing process where the exception is thrown about 80% of the time.
This rules out pretty much all the Google results on the subject as the problems there are usually caused by database connection issues in the transaction or firewalls.
There are no events in any of the event logs (on the build machine running the tests or the development database server) that suggest there is a problem. In fact, the only related event message I see is on the database machine-- a "MSDTC: Session idle timeout over, tearing down the session." event occurs shortly after I run a test.
I'm not sure how to continue trying to find this issue.
Are there any ways to generate details from within the code on the transaction state (I'm using C# with .NET 3.5)?
Is there any way to have the event log give me more information to help track this down?
The involved machines are a Windows 2000 Server (db) and Windows Serer 2003 (build) if this helps to find the right tools.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
引发错误的测试可能不是错误所在的地方。
可能是在该测试之前运行的测试之一导致事务处于打开状态或出现其他问题。
然后,当运行测试时,它会在联系 MSDTC 时收到错误。
找到它的方法是从失败的测试开始,单独运行它,它应该会通过。然后一次添加一个(或多个)其他测试,直到失败。
The test that is throwing the error is probably not where the error is.
It could be one og the tests that is run before that test that is leaving a transaction open or some other problem.
Then when the test that is run it gets an error when it contacts the MSDTC.
The way to find it is to start with just the test that fails, run that alone, it should pass. Then add the other tests one (or several) at a time until it fails.