I had a look at this a while ago and noticed a few oddities in behaviour when mixing SessionScope, TransactionScope and DifferentDatabaseScope depending on which was nested inside the other. I could make individual scenarios work but always at the expense of a different one - I never managed to make them all work. In the end I left it and decided not to mix DifferentDatabaseScope with the others. Dave.
________________________________ From: [email protected] [mailto:[email protected]] On Behalf Of Tyler Burd Sent: 15 January 2009 23:44 To: [email protected] Subject: DifferentDatabaseScope bug & patch My team has been running into a problem when using DifferentDatabaseScope. I have attached a patch that fixes the issue, but let me describe the issue first... When using DifferentDatabaseScope in the following manner: using (var s = new SessionScope()) { IDbConnection conn1; //initialize and open conn1 using (var diffScope1 = new DifferentDatabaseScope(conn1)) { } conn1.Dispose(); IDbConnection conn2; //initialize and open conn1 using the *SAME* connection string as conn1 using (var diffScope2 = new DifferentDatabaseScope(conn2)) { } conn2.Dispose(); } We started to see all kinds of "connection already closed/disposed" errors in the second DifferentDatabaseScope. I tracked the problem down to the Castle.ActiveRecord.Framework.Scopes.KeyHolder class and the DifferentDatabaseScope.GetSession method. GetSession looks up a session using a key that is composed of a connection string and a few other items. The problem is that the keys for conn1 and conn2 are the same, so all operations in the second scope were trying to use conn1. My patch adds the hashcode of the connection to the KeyHolder class, so that connections can be distinguished even when they have the same connection strings. This is probably not bullet proof either, but in my tests (PostgreSQL and SQL Server) it works like a charm. I would be happy to create an issue to document this patch, but I wanted to put it out there first to make sure it's not something that someone's already aware of. -Tyler Email disclaimer: The information contained in this e-mail is confidential and may be legally privileged. If you are not the intended recipient, please do not read, copy, disclose or otherwise use it. Please notify the sender of the delivery error by return e-mail and delete it and all copies from your system. Internet communications cannot be guaranteed to be timely, secure, or error free. Any views or opinions expressed in this e-mail are those of the author only and Albany Software Limited does not accept any liability for its contents, errors or omissions. Registered in England & Wales No: 2366012 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Development List" 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/castle-project-devel?hl=en -~----------~----~----~----~------~----~------~--~---
