Skip to content

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

Description

@simader

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions