6

I need a lot of DB processing done in a single transaction, including some processing using NHibernate.

To make everything work in the same transaction, I'm using NHibernate's Session to start it, and enlist the the commands for the other work in it.

Everything goes OK until I commit. At that time I get a transaction timeout.

How can I set the NHibernate transaction timeout value sufficiently high?

We use FluentNHibernate.

Oliver
  • 9,239
  • 9
  • 69
  • 100
k.c.
  • 1,755
  • 1
  • 29
  • 53

1 Answers1

5

After some trial and lots of error I found this:

It appears that NHibernate takes the "TransactionManager.DefaultTimeout" value.

It can be set via

 <system.transactions>
     <defaultSettings timeout="01:00:00" />
 </system.transactions>

in the app/web config

If it is set to a value higher than TransactionManager.MaximumTimeout the transaction timeout will default to that. If you need longer you can lengthen that time by updating the "machine.config" for your .Net framework version with:

<system.transactions>
    <machineSettings maxTimeout="01:00:00" />
</system.transactions>
k.c.
  • 1,755
  • 1
  • 29
  • 53
  • 1
    I don't think this is a great solution as this is set globally, There should be a specific timeout for a specific transaction. – Daniel Aug 21 '20 at 18:28
  • 1
    @Daniel it was the best I could come up with in 2013, and did the trick for us. It's 7 years later now, do you know if a better solution has come up? Then please post it here. – k.c. Aug 26 '20 at 06:54