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

Multiple includes let MySql Server crash #901

Closed
hromkes opened this issue Oct 28, 2019 · 2 comments
Closed

Multiple includes let MySql Server crash #901

hromkes opened this issue Oct 28, 2019 · 2 comments
Assignees

Comments

@hromkes
Copy link

hromkes commented Oct 28, 2019

Steps to reproduce

Consider the following query:
var result = await _dbContext.MainTable
.Include(m => m.Collection1)
.Include(m => m.Collection2)
.Include(m => m.Collection3)
.Include(m => m.Collection4)
.Include(m => m.Collection5)
.Include(m => m.Collection6)
.Include(m => m.Collection7)
.Include(m => m.Collection8)
.Include(m => m.Collection9)
.Include(m => m.Collection10)
.SingleOrDefaultAsync(m => m.Id == request.Id);

Assume that each related table contains 10 records for the given id.

In version 2.2 a subquery was generated for each collection.
So 10 queries were executed which each returned 10 rows.

In the 3.0 pre-release a single query is generated with a left join for each related table.
Each left join will multiply the number of rows in the temporary result.
So if each related table contains 10 records for the given id, a temporary result of 10000000000 rows is created.

The issue

My MySql server cannot handle this.
On my machine MySql claims all available memory
My machine begins to swap memory.
Memory usage goes to 100%
Disk activity goes to 100%
My entire machine hangs.

Further technical details

MySQL version: 8.0.16
Operating system: Windows 10 Professional
Pomelo.EntityFrameworkCore.MySql version: 3.0.0-rc1.final
Microsoft.AspNetCore.App version: 3.0

See attached image which shows the memory usage development, immediately after the query is started:
memory usage

@lauxjpn
Copy link
Collaborator

lauxjpn commented Oct 28, 2019

This is a duplicate of #874
You will find everything you need to know in there.

@lauxjpn lauxjpn closed this as completed Oct 28, 2019
@lauxjpn lauxjpn self-assigned this Oct 28, 2019
@mguinness
Copy link
Collaborator

Specifically dotnet/efcore#18017 upstream.

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

No branches or pull requests

3 participants