I have a messaging system that runs calculations in the background and stores the results in the database. If I run on more than 1 thread and insert records through the web interface rapidly I will end up with the follow 2 exceptions in my service log:
NHibernate.Event.Default.AbstractFlushingEventListener [(null)] - Could not synchronize database state with session NHibernate.HibernateException: An exception occurred when executing batch queries ---> System.Data.SqlClient.SqlException: Transaction (Process ID 51) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction. NHibernate.Impl.AbstractSessionImpl [(null)] - DTC transaction prepre phase failed NHibernate.HibernateException: An exception occurred when executing batch queries ---> System.Data.SqlClient.SqlException: Transaction (Process ID 51) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction. If I switch over to a single thread the problem appears to stop. I think this makes sense to me. with >1 threads 2 threads attempt to access the same record at the same time = dead lock. the message tells me to re-run the transaction. how do I do that in RSB? is there a Transaction.TryAgain(); method? I thought part of the advantage of messaging was parallel processing. If I only run on 1 thread is there any real benefit to messaging? some other back ground on this procedure. 1. in a NH post insert/update/delete event I send a message to start calculating. the service picks up this message and works its magic. 2. the isolation level for the windows service the RSB default, serializable i believe. the isolation level for the website is read committed. 3. it appears that after the deadlock the current saga stops altogether. 4. right now I'm testing on an older box I'm pretty sure it's a single proc box with a gig of RAM. 5. both the website and service are hitting the database. the website does CRUD for the immediate input. the service runs the calculations and CRUD against the database. 6. the tables updated by the website are read by the service and vice versa. wouldn't think this would be an issue though. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Rhino Tools Dev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rhino-tools-dev?hl=en -~----------~----~----~----~------~----~------~--~---
