Recently I've been encountering ArgumentOutOfRangeExceptions in AfterTransactionCompletionProcessQueue.AfterTransactionCompletion that seem to happen every day now, though it seems to only occur when the system is under relatively heavy load. We have been using NHibernate with this application for over five years, and this problem only started happening this week. We have not encountered it in any of our testing environments, and I've so far been unsuccessful at constructing a unit test or test application that can reproduce the problem.
The stack trace I get isn't very helpful: An AssertionFailure occurred - this may indicate a bug in NHibernate or in your custom types. System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) at System.Collections.Generic.List`1.get_Item(Int32 index) at NHibernate.Engine.ActionQueue.AfterTransactionCompletionProcessQueue.AfterTransactionCompletion(Boolean success) Note that there isn't anything else in the stack trace or exception message. This corresponds to the behaviour I'm seeing in the application as well, as the exception seems to happen on its own separate thread where the top-level exception handler from each thread created by the application does not appear to have been invoked. This then causes the entire process to terminate. Each application thread has its own unique session instance and we do not share entities loaded with NHibernate across threads. The application uses NServiceBus to interact with MSMQ, so most (if not all) operations are part of a distributed transaction using TransactionScopes. Looking at the code associated with the stack trace, I'd be suspicious that there may be a race condition in the method, as the only list in the method is processes, and the loop evaluates the size before the loop runs, but not on subsequent iterations. That being said, I'm not familiar enough with the internals of NHibernate to know if this code is expected to run on multiple threads simultaneously or not. I think this is essentially the same problem that someone reported in 2010 as NH-2465, but that case was closed due to incomplete information. Is there anything I can do to capture more information that might be relevant to reproducing this problem? Is there anything I could do to mitigate it? If relevant, we are running Windows Service 2012 R2 on the machine where this occurs, and we are using .Net 4.6.2 with NHibernate 4.0.3 and SQL Server 2014. We have been using NHibernate 4.0.3 for about two years now without issue until now, though we did update to SQL Server 2014 about a month ago. Thanks. Dennis -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/d/optout.
