Thanks for your help here, I'll pass on this information as a good lead for 
further investigation.

On Saturday, February 11, 2017 at 10:24:32 AM UTC, Oskar Berggren wrote:
>
> Hi,
>
> From the comments on that class:
>     /// There is meant to be a one-to-one correspondence between a 
> SessionImpl and /// a PersistentContext.
>
> A SessionImpl is the same as "a session", and sessions are not safe for 
> use from multiple threads concurrently. So I think the first thing for you 
> to check is to carefully examine if you might be accessing some session 
> instance from multiple threads. This can be a bit devious of course... 
> consider that "accessing an entity" loaded from session A must be regarded 
> as "accessing session A" (unless the entity have been detached) even if you 
> might not reference the session directly in that part of the code. So 
> beware if you are loading entity somewhere are allowing them to linger in 
> working memory for access from multiple requests/threads.
>
> /Oskar
>
>
>
>
>
>
>
> 2017-02-10 11:01 GMT+00:00 <[email protected] <javascript:>>:
>
>> Hi there, I am looking for some general advice, we have 2 web servers 
>> which frequently (once to twice a day) hit 100% CPU, using process explorer 
>> I can drill into the W3WP.exe and its associated threads to determine the 
>> cause, and it appears to be NHibernate when trying to either access or add 
>> to collections in the 'StatefulPersistenceContext' class. I have provided 
>> an example stack trace of the process which has been captured directly from 
>> the web server during high CPU, there are always 2-3 threads with the same 
>> stack trace:
>>
>> mscorlib.dll!System.Collections.Generic.Dictionary`2.FindEntry+0x12c
>> mscorlib.dll!System.Collections.Generic.Dictionary`2.TryGetValue+0x14
>>
>> NHibernate.dll!NHibernate.Engine.StatefulPersistenceContext.AddCollection+0x170
>>
>> NHibernate.dll!NHibernate.Engine.StatefulPersistenceContext.AddUninitializedCollection+0x9e
>> NHibernate.dll!NHibernate.Type.CollectionType.GetCollection+0x344
>> NHibernate.dll!NHibernate.Type.CollectionType.ResolveKey+0x58
>> NHibernate.dll!NHibernate.Type.CollectionType.Assemble+0x12b
>> NHibernate.dll!NHibernate.Type.TypeHelper.Assemble+0x2ab
>> NHibernate.dll!NHibernate.Cache.Entry.CacheEntry.Assemble+0xae
>> NHibernate.dll!NHibernate.Cache.Entry.CacheEntry.Assemble+0x12b
>>
>> NHibernate.dll!NHibernate.Event.Default.DefaultLoadEventListener.AssembleCacheEntry+0x601
>>
>> NHibernate.dll!NHibernate.Event.Default.DefaultLoadEventListener.LoadFromSecondLevelCache+0xa30
>>
>> NHibernate.dll!NHibernate.Event.Default.DefaultLoadEventListener.DoLoad+0x561
>>
>> NHibernate.dll!NHibernate.Event.Default.DefaultLoadEventListener.Load+0x3be
>>
>> NHibernate.dll!NHibernate.Event.Default.DefaultLoadEventListener.ProxyOrLoad+0x267
>>
>> NHibernate.dll!NHibernate.Event.Default.DefaultLoadEventListener.OnLoad+0x8b4
>> NHibernate.dll!NHibernate.Impl.SessionImpl.FireLoad+0x152
>> NHibernate.dll!NHibernate.Impl.SessionImpl.InternalLoad+0x155
>> NHibernate.dll!NHibernate.Type.EntityType.ResolveIdentifier+0x26a
>> NHibernate.dll!NHibernate.Type.ManyToOneType.Assemble+0xff
>>
>> NHibernate.dll!NHibernate.Collection.PersistentBag.InitializeFromCache+0x16c
>> NHibernate.dll!NHibernate.Cache.Entry.CollectionCacheEntry.Assemble+0x66
>>
>> NHibernate.dll!NHibernate.Event.Default.DefaultInitializeCollectionEventListener.InitializeCollectionFromCache+0xa8d
>>
>> NHibernate.dll!NHibernate.Event.Default.DefaultInitializeCollectionEventListener.OnInitializeCollection+0x56f
>> NHibernate.dll!NHibernate.Impl.SessionImpl.InitializeCollection+0x18c
>>
>> NHibernate.dll!NHibernate.Collection.AbstractPersistentCollection.Initialize+0xf9
>>
>> NHibernate.dll!NHibernate.Collection.AbstractPersistentCollection.Read+0x35
>>
>> NHibernate.dll!NHibernate.Collection.Generic.PersistentGenericBag`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator+0x46
>>
>> This appears to be a race condition, we are using version 3.3.3.GA. I've 
>> looked through the source code for a few versions (3.3.3.SP1 and 4.0.0.GA) 
>> but the code is the same so I am led to believe this could be a 
>> configuration issue rather than a bug in NHibernate. 
>>
>> Some googling revealed a similar issue posted on S/O and was fixed:
>>
>>
>> http://stackoverflow.com/questions/26536361/nhibernate-enumerating-the-same-collection-on-multiple-threads
>>
>> Can anyone offer any advice on this at all?
>>
>>
>> -- 
>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/nhusers.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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.

Reply via email to