I just started observing this in our system as usage is slowly ramping up. 
 There appears to be JIRA issue #NH-3050 ( 
https://nhibernate.jira.com/browse/NH-3050 ) for this, but it is as of yet 
unresolved.

On Monday, September 5, 2011 5:19:19 AM UTC-4, Yohei Iwano wrote:
>
> I'm sorry for my poor English. But this happens in our system too. 
>
> At first, let me explain my understanding. 
> When I query linq contains collection parameter like this 
>  from x in session.Query<SomeEntity> where 
> collectionParam.Contains(x.Col1) select x 
>
> It will process like this 
>
> 1. Retrieve NhLinqExpression Query Plan from QueryPlanCache 
> 2. Retrieve ExpandedQueryExpression Query Plan from QueryPlanCache 
>
> but if the collection parameter contains only one value(like "var 
> collectionParam = new int[] {100}"). 
> It will process like this 
>
> 1. Retrieve NhLinqExpression Query Plan from QueryPlanCache 
> 2. Retrieve NhLinqExpression(not ExpandedQueryExpression!) Query Plan 
> from QueryPlanCache 
>
> this happens because of problem in creation of "query plan cache key". 
> When the collection parameter contains only one value, 
> NhLinqExpression and ExpandedQueryExpression both make same query plan 
> cache key. 
> (see ExpressionQueryImpl.ExpandParameters method) 
>
> Normally, this process works fine. But if the GC occurs between 1 and 
> 2, and the NhLinqExpression objects are collected, 
> ExpandedQueryExpression(which is the same query plan cache key as 
> NhLinqExpression) is now going to cache. 
> In this time, softReferenceCache object in the SoftLimitMRUCache is 
> poisoned. And next time you try to execute linq, InvalidCastException 
> occurs... 
>
> I'm caching SessionFactory object in static field, and reuse it 
> between all threads/requests. The pollution of QueryPlanCache is 
> really serious problem... 
> (Additionally, I'm using ThreadStaticSessionContext to share Session 
> object between application layers. So I cannot recreate SessionFactory 
> object easily...) 
>
> Yohei 
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/nhusers/-/DQiO7EiYa_8J.
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