Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the timeout on a NHibernate transaction

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.

like image 492
k.c. Avatar asked Feb 05 '13 14:02

k.c.


1 Answers

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>
like image 188
k.c. Avatar answered Oct 30 '22 15:10

k.c.