-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
ToListAsync on a query with thousands of entries inside a "where contains" statement requires MARS=True (inside Docker container) #23560
Comments
Seems to be an exact duplicate of #14737. As metioned in that issue, I get the same error also with non async methods. So, ToList() with 100k entries results in this exception:
But there seem to be not an exact solution. I will now try to implement "workarounds" mentioned in #13617. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ToListAsync() thorws Exceptions on a big query
Recently, we had a production issue in one of our services. We managed to reproduce the issue and found out, that
IQueryable<>.ToListAsync()
failes on a.Where(x => myIds.Contains(x.Id))
query, whenmyIds
contains thousands (> ~3500) of entries. This behavior could be reproduced on a Azure Sql Database withMultipleActiveResultSets=False
in the connection string. Furthermore, this behavior only occures on Linux (tested inside a Docker container). If we replace.ToListAsync()
with.ToList()
, the error is gone. On a dockerized MSSQL Server 2019 the error also won't occur.We tested different setups with the code bellow. Here are the results (green = OK, red = NOK)
Hint: We need
MultipleActiveResultSets
set toFalse
because we had this issue, which isn't resolved yet: dotnet/SqlClient#422Code
The following listings will show our project where we reproduced the bug. Notice, that we are using docker-compose and an Azure Sql Database.
Program.cs
(var connectionString = azure;
), the database (local
orazure
) can be controlled.Program.cs
(Enumerable.Range(1, 4000)
) the amount of entries can be controlled.docker-compose up --build
EfCoreBug.csproj
File:Program.cs
File:Dockerfile
docker-compose.yml
Two different Exceptions
The code above will reproduce the following exception, when running the failing scenario:
Another Exception we sometimes get on the production system is the following:
Include provider and version information
EF Core version: 3.1.10
Database provider: Microsoft.EntityFrameworkCore.SqlServer 3.1.10
Target framework: netcoreapp3.1
Operating system: WIndows / Linux (Docker)
IDE: Visual Studio 2019 16.8.1
The text was updated successfully, but these errors were encountered: