无法在与NHibernate分布式事务中登记 [英] Unable to enlist in a distributed transaction with NHibernate

查看:434
本文介绍了无法在与NHibernate分布式事务中登记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到在单元测试,其中甲骨文抛出的异常的消息无法在分布式事务中登记的问题。我们使用ODP.net和NHibernate。这个问题使得一定数量的提交到嵌套事务内部的数据库之后出现。烦人,这是失败的持续集成服务器(Windows Server 2003 R2 SP1)上,而不是我的开发机器(XP SP2)上。

I'm seeing a problem in a unit test where Oracle is thrown an exception with the message "Unable to enlist in a distributed transaction". We're using ODP.net and NHibernate. The issue comes up after making a certain number of commits to the database inside nested transactions. Annoyingly, this is failing on the continuous integration server (Windows Server 2003 R2 SP1), and not on my dev machine (XP SP2).

这是一个小的(ISH这个问题的)摄制:

This is a small(ish) repro of the issue:

using (new TransactionScope())
{
	for (int j = 0; j < 15; j++)
	{
		using (var transactionScope = new TransactionScope(TransactionScopeOption.Required))
		using (var session = sessionFactory.OpenSession())
		{
			for (int i = 0; i < 200; i++)
			{
				var obj = [create new NHibernate mapped obj]
				session.Save(obj);
			}
			session.Flush();
			transactionScope.Complete();
		}
	}
}



连接字符串我们使用的是:

The connection string we're using is:

数据源=服务器;用户ID =用户;密码=密码;争取= TRUE;

Data Source=server;User Id=user;Password=password;Enlist=true;

显然,这看起来像一个重手的东西是干什么的,但产品代码的情况比较复杂(外部事务环路和内部交易循环非常分开)。

Obviously this looks like a heavy handed thing to be doing, but the case of the product code is more complex (the outer transaction loop and inner transaction loop are very separated).

在构建服务器,它可靠地弹了在外环(J)的第五迭代。看到它通过我的本地机器上,我想知道,如果这是打某种交易或连接配置的限制?

On the build server, it reliably bombs out on the fifth iteration of the outer loop (j). Seeing as it passes on my local machine, I'm wondering if this is hitting some kind of configured limit of transactions or connections?

任何人有什么预感,我可以尝试?解决它的明显的方法是更改​​代码,以更好地处理这种情况,但我只是想知道为什么它的工作原理一台机器,而不是在另一个上。谢谢!

Anyone got any hunches I can try out? The obvious way to fix it is to change the code to better handle this situation, but I'd just like to understand why it works on one machine and not on another. Thanks!

推荐答案

在我看来,这与您的Oracle数据库的配置做的。

It seems to me this has to do with your Oracle database configuration.


  • 请您使用在两个环境中(我假设没有)?在同一数据库服务器

  • 的数据库版本你使用哪种(我?'就带10G)

下面是我可以根据这些假设发现:

Here is what I could find based on these assumptions :


  • 检查的调整Microsoft事务服务器性能。为 ORAMTS_NET_CACHE_MAXFREE默认值为参数设置为5,这可能的有关您的问题。在采取任何行动之前,请阅读整个页面,但(你可以尝试增加会话 PROCESSES 参数太)。

  • 您可以的启用跟踪甲骨文MTS ,了解什么是真正发生的事情有

  • 如果仍然坚持,我想你可以的启用跟踪的MSDTC ,以试图获得更深入的了解。

  • Check Tuning Microsoft Transaction Server Performance. The default value for the ORAMTS_NET_CACHE_MAXFREE parameter is set to 5, which may be related to your problem. Read the whole page before taking any action, though (you could try to increase the SESSIONS and PROCESSES parameters too).
  • You could enable tracing on Oracle MTS to see what is really happening there.
  • If still stuck, I guess you could enable tracing on MSDTC to try to get more insight.

这篇关于无法在与NHibernate分布式事务中登记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆