-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[release/9.0] Dispose related readers in GroupBySplitQueryingEnumerable (#36484) #36490
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixes dotnet#34280 (cherry picked from commit 08f094b)
SamMonoRT
approved these changes
Aug 3, 2025
cc @artl93 |
AndriySvyryd
approved these changes
Aug 4, 2025
Approved via email. |
This was referenced Sep 9, 2025
This was referenced Sep 17, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Port of #36484 for EF 9.0.x.
Fixes #34280
Description
When a user executes a LINQ query that has a final GroupBy() (GroupBy as the very last operator), and executes as a split query, EF does not properly dispose the database reader(s) it uses to read back the results (these are IDisposable).
Customer impact
Depending on the provider, when executing a LINQ query that uses a final GroupBy() and is configured for split querying, the database connection may get leaked and never returned to the connection pool. This later leads to an exhausted connection pool and to an application failure in a way that's hard to track down and connect to the actual problematic EF LINQ query.
How found
Two users reported.
Regression
No - this bug was present when the final GroupBy feature was first introduced in EF 7.0 (in #19929)
Testing
Adding test coverage here is quite difficult/impractical - the bug is that a certain internal resource (DbDataReader) doesn't get disposed, which isn't something visible we can check.
Risk
Extremely low. The fix is very targeted and simply does the as for very similar other code (e.g. non-GroupBy SplitQueryingEnumerable).