zzzprojects / EntityFramework.DynamicFilters

Global filtering for Entity Framework.
https://entityframework-dynamicfilters.net/
MIT License
501 stars 86 forks source link

ConcurrentDictionary is breaking my Oracle 11g unit tests #180

Closed worthy7 closed 2 years ago

worthy7 commented 2 years ago

https://github.com/zzzprojects/EntityFramework.DynamicFilters/blob/bd36394d39b53fbb592ddf1f06bce82aac8ef4bb/src/EntityFramework.DynamicFilters.Shared/DynamicFilterExtensions.cs#L1160

The new "ConcurrentDictionary", I believe is causing errors at least in Oracle.

  Message: 
System.Data.Entity.Core.EntityCommandCompilationException : An error occurred while preparing the command definition. See the inner exception for details.
---- System.NotSupportedException : A second operation started on this context before a previous asynchronous operation completed. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context. Any instance members are not guaranteed to be thread safe.

  Stack Trace: 
<omitted because its just my test function stack trace>
----- Inner Stack Trace -----
ThrowingMonitor.EnsureNotEntered()
InternalContext.ExecuteSqlQuery[TElement](String sql, Nullable`1 streaming, Object[] parameters)
InternalContext.ExecuteSqlQueryAsIEnumerator[TElement](String sql, Nullable`1 streaming, Object[] parameters)
InternalContext.ExecuteSqlQuery(Type elementType, String sql, Nullable`1 streaming, Object[] parameters)
InternalSqlNonSetQuery.GetEnumerator()
DbRawSqlQuery`1.GetEnumerator()
Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
<>c__DisplayClass65_0.<OracleVersion>b__0(String k)
**ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)**
DynamicFilterExtensions.OracleVersion(DbContext context)
DynamicFilterQueryVisitorCSpace.DoesNotSupportElementMethod(DbContext context)
DynamicFilterInterceptor.TreeCreated(DbCommandTreeInterceptionContext interceptionContext)
<>c.<Created>b__3_0(IDbCommandTreeInterceptor i, DbCommandTreeInterceptionContext c)
InternalDispatcher`1.Dispatch[TInterceptionContext,TResult](TResult result, TInterceptionContext interceptionContext, Action`2 intercept)
DbCommandTreeDispatcher.Created(DbCommandTree commandTree, DbInterceptionContext interceptionContext)
DbProviderServices.CreateCommandDefinition(DbCommandTree commandTree, DbInterceptionContext interceptionContext)
EntityCommandDefinition.ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree, DbInterceptionContext interceptionContext, IDbDependencyResolver resolver, BridgeDataReaderFactory bridgeDataReaderFactory, ColumnMapFactory columnMapFactory)
JonathanMagnan commented 2 years ago

Hello @worthy7 ,

You are right, the error is caused by the SqlLQuery which is used inside for this ConcurrentDictionary.

However, my question is more about how/why is happening? Such as do you share this context in multiple threads or is it really a bug in our library!

Do you think you could create a runnable project with the issue? It doesn’t need to be your project, just a new solution with the minimum code to reproduce the issue. You can send it in private here: info@zzzprojects.com

It will be easier for us to understand/try to fix it if we already have a project that throw this error.

Best Regards,

Jon

worthy7 commented 2 years ago

Yes, I took a look and realized that it needs more investigating, as previous 3.2.0 is also erroring.

I'll hopefully do this today.

On Fri, 21 Jan 2022, 00:53 Jonathan Magnan, @.***> wrote:

Hello @worthy7 https://github.com/worthy7 ,

You are right, the error is caused by the SqlLQuery which is used inside for this ConcurrentDictionary.

However, my question is more about how/why is happening? Such as do you share this context in multiple threads or is it really a bug in our library!

Do you think you could create a runnable project with the issue? It doesn’t need to be your project, just a new solution with the minimum code to reproduce the issue. You can send it in private here: @.***

It will be easier for us to understand/try to fix it if we already have a project that throw this error.

Best Regards,

Jon

— Reply to this email directly, view it on GitHub https://github.com/zzzprojects/EntityFramework.DynamicFilters/issues/180#issuecomment-1017649973, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABEKWH4LIFY546XJWK3DEUTUXAVYVANCNFSM5MMDDLSQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.*** com>

worthy7 commented 2 years ago

Problem is nothing to do with EF.DF at least, closed - sorry for the trouble!