DataObjects-NET / dataobjects-net

https://dataobjects.net
MIT License
60 stars 23 forks source link

Session dispose exception #305

Open letarak opened 1 year ago

letarak commented 1 year ago

DO 7.0 Sorry, can not reproduce in test environment Catch this exception three times

System.ArgumentNullException: Value cannot be null. (Parameter 'node')
   at System.Collections.Generic.LinkedList`1.ValidateNode(LinkedListNode`1 node)
   at Xtensive.Collections.TopDeque`2.PopBottom() in /_/Orm/Xtensive.Orm/Collections/TopDeque.cs:line 180
   at Xtensive.Caching.LruCache`2.Clear() in /_/Orm/Xtensive.Orm/Caching/LruCache{TKey, TItem}.cs:line 159
   at Xtensive.Orm.Session.DisposeImpl(Boolean isAsync) in /_/Orm/Xtensive.Orm/Orm/Session.cs:line 661
   at Xtensive.Orm.Session.Dispose() in /_/Orm/Xtensive.Orm/Orm/Session.cs:line 614
System.InvalidOperationException: The LinkedList node does not belong to current LinkedList.
   at System.Collections.Generic.LinkedList`1.ValidateNode(LinkedListNode`1 node)
   at Xtensive.Collections.TopDeque`2.PopBottom() in /_/Orm/Xtensive.Orm/Collections/TopDeque.cs:line 180
   at Xtensive.Caching.LruCache`2.Clear() in /_/Orm/Xtensive.Orm/Caching/LruCache{TKey, TItem}.cs:line 159
   at Xtensive.Orm.Session.DisposeImpl(Boolean isAsync) in /_/Orm/Xtensive.Orm/Orm/Session.cs:line 661
   at Xtensive.Orm.Session.Dispose() in /_/Orm/Xtensive.Orm/Orm/Session.cs:line 614
alex-kulakov commented 1 year ago

Hello @letarak , so this appears in some conditions on production? Does it fail all the time?

alex-kulakov commented 1 year ago

Did the problem appear on a version which was publicly available as a release (7.0.3, 7.0.2 etc.) or it is on latest changes on 7.0 branch? I need the version or the commit in case it was built by you on some commit of 7.0 branch. This is important to identify whether it is old problem or has just appeared.

letarak commented 1 year ago

Yes, catch on production, but very rarely (5 times total in 3-4 month) Precise version 7.0.3

Exception seen only in two blocks of code, each of them use nested session scope Nested session use entity instance from outer scope Hope this helps

alex-kulakov commented 1 year ago

Hmmm... I'll try to reproduce it but probably it will be a hard-to-catch bug. Thank you for the info. If some additional details appear, please post them.

alex-kulakov commented 1 year ago

I stumbled across this post in which it is told that errors like "The LinkedList node does not belong to current LinkedList" in concurrent access. Are you sure that there is no hidden switching between sessions? Do you use Session.Activate() and Session.Current in such cases?

letarak commented 1 year ago

No, we do not use Session.Activate() maybe Session.Current with custom resolver and this can activate session without our help :)

I need check this