zzzprojects/EntityFramework.DynamicFilters

ConcurrentDictionary is breaking my Oracle 11g unit tests

worthy7 opened this issue · 3 comments

return _OracleInstanceVersions.GetOrAdd(context.Database.Connection.ConnectionString, k =>

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)

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

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