Hi All

I've encountered what looks like a race condition in the interaction
between LinFu and NHibernate when sharing a SessionFactory between
multiple threads and I would like to know if this is the appropriate
forum to discuss this.

I would also appreciate any advice on how I could write a unit test to
demonstrate this condition before I submit a bug report either to
NHibernate's JIRA or to Philip Laureano.

The condition I am experiencing can occur when a SessionFactory is
passed into multiple threads which are doing identical jobs.

When they start at the same time, they each open a session and attempt
to load a instance of a persistent class (SalesOrder) using the
Criteria API.

In LinFu, there is a cache for the proxies it creates and this cache
is backed by a static generic dictionary. The generic dictionary is
not thread safe but it is updated from all threads as they attempt to
add the proxy to the dictionary. This happens in response to a call to
ICriteria.List<SalesOrder>.

The inner exception for info is:

 NHibernate.HibernateException: Creating a proxy instance failed --->
System.IndexOutOfRangeException: Index was outside the bounds of the
array.
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue
value, Boolean add)
   at LinFu.DynamicProxy.ProxyCache.StoreProxyType(Type result, Type
baseType, Type[] baseInterfaces)
   at LinFu.DynamicProxy.ProxyFactory.CreateProxyType(Type baseType,
Type[] baseInterfaces)
   at LinFu.DynamicProxy.ProxyFactory.CreateProxy(Type instanceType,
IInterceptor interceptor, Type[] baseInterfaces)
   at NHibernate.ByteCode.LinFu.ProxyFactory.GetProxy(Object id,
ISessionImplementor session)
   --- End of inner exception stack trace ---

To work around I have found that loading up an instance of a
SalesOrder before starting the threads cures this issue.

Cheers

Andrew
-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" 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/nhusers?hl=en.


Reply via email to