transaction isolation - Nhibernate : generates insert then update statements, in multithreaded environment leads to deadlock issues -
I have experienced the following scenario when using NHibernate with SQL Server 2005.
I have a business process that includes the following steps:
- Start the transaction
- Create nhibernate map objects
- Save nhibernate map object
- Other business workflow steps
- Update nhibernate map object in step 2
- Commit transaction
This works fine in a single threaded environment. However, when there is a multi-thread load test that runs the same usage case on different entities, I came to know that I had to face a number of deadlocks. The level of transaction segregation was left on the default settings of committed commitments.
After the investigation, I have found that the reason for the problem is that vesting is involved; Step 2 & amp; Updated statement for the unit created in; Updated to step 5. By further testing, I understand that the update statement is locking the entire table & amp; Not only the rows are being updated, this leads to the deadlock when someone enters another thread or attempts to access the table for updates
Question 1: Does this update? It is possible to nibbing to lock the rows, i.e. the row lock is applied when issuing an update?
So far I did not find any way to get a nhibernate to run a single insertion statement as opposed to putting one and then updating the statement.
Question 2: Does anyone know of a configuration option to change this behavior?
I switch to snapshot isolation by setting the deadlock level on the deadlocked multi-threaded load test on my SQL Server database and for the snapshot
I would be interested to hear if anyone Have experienced similar issues. You should take care of it. It is advisable to make this minimal transaction possible (in the period).
If it is not really possible, make changes in the configuration of your transaction segregation in the configuration, but it is not advised.
Comments
Post a Comment