使用 NHibernate TransactionScope 时出现超时异常

发布于 2024-09-25 20:26:48 字数 558 浏览 3 评论 0原文

这是超时设置为无限时间时的超时异常的延续(我还看到未回答的 SqlConnection 和 TransactionScope Timeout 问题)。

我在 NHibernate、C# 3.5 上使用 CastleProject ActiveRecord。我在 TransactionScope 内对数据库进行了多次后续插入。其中之一(随机,每次不同)因 TimeoutException 失败。无论我在配置文件中设置哪个超时(10 小时),这都没关系。如果我不使用事务范围,它可以工作(但太慢)。看来,NHibernate事务的默认超时时间是30秒,并且不受hibernate.command_timeout值的影响。

正确吗?如何克服这个问题?

This is continuation of Timeout exception when timeout set to infinite time (and I also see unanswered SqlConnection and TransactionScope Timeout question).

I am using CastleProject ActiveRecord over NHibernate, C# 3.5. I have multiple subsequent inserts to a database within TransactionScope. One of them (random, different each time) fails with TimeoutException. Whichever timeout I set in my config file (10 hours), this does not matter. If I do not use transaction scope, it work (but too slow). It seems, NHibernate transaction has default timeout 30 second and is not affected by hibernate.command_timeout value.

Is it correct? How to overcome this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

腹黑女流氓 2024-10-02 20:26:48

您是否尝试过增加连接超时值?

在连接字符串中包含“Connection Timeout=somehighvalueinsecondshere”。

http://msdn.microsoft.com/en -us/library/system.data.sqlclient.sqlconnection.connectiontimeout.aspx

Have you tried increasing your connection time out value?

Include "Connection Timeout=somehighvalueinsecondshere" in the connection string.

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectiontimeout.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文