Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queries with many Guids in Linux: System.InvalidOperationException: Invalid operation. The connection is closed. #792

Closed
simader opened this issue Nov 12, 2020 · 1 comment · Fixed by #796

Comments

@simader
Copy link

simader commented Nov 12, 2020

I have a query which runs under windows without problems, but if we get around 4000 guids there the query fails on a Linux App Service
var issues = await context.Issues.Where(i => guids.Contains(i.Id)).ToListAsync();

Exception message: System.InvalidOperationException: Invalid operation. The connection is closed.
Stack trace:
at Microsoft.Data.SqlClient.SqlCommand.<>c.b__164_0(Task1 result) at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.AsyncEnumerator.InitializeReaderAsync(DbContext _, Boolean result, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func4 operation, Func4 verifySucceeded, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.AsyncEnumerator.MoveNextAsync()
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable1 source, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable1 source, CancellationToken cancellationToken)
at App1.UnitTestProject1.WhereClauseTest.InternalTest(SampleContext context, Int32 amount) in /home/vsts/work/1/s/App1/App1.UnitTestProject1/WhereClauseTest.cs:line 85
at App1.UnitTestProject1.WhereClauseTest.TestWhereClauseWithManyIds_OnSqlServer() in /home/vsts/work/1/s/App1/App1.UnitTestProject1/WhereClauseTest.cs:line 53

To reproduce

Enclosed i build a simple sample, which runs under a windows maschine, but on a Linux Build Server it is failing:
EfCoreLinux.zip
Not please add correct: SQL Azure Connection String

Further technical details

Microsoft.Data.SqlClient version: EF Core 3.1.10 (SqlClient 1.1.3) but I also tried newer versions, which had similar problems
.NET target: Core 3.1
SQL Server version: Microsoft Azure SQL
Operating system: Ubuntu 18.04

@cheenamalhotra
Copy link
Member

Hi @simader

This looks related to issues #786, #459 and #54
There's a likely fix from #579 which is currently under further improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
2 participants