Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[8.0] Resolve query logger from QueryContext in shaper generation (#36758)#36779

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
roji merged 1 commit intodotnet:release/8.0-stagingfromroji:JsonLeak8
Sep 15, 2025

Conversation

@roji
Copy link
Member

Instead of closing over the current scoped logger, causing a leak.

Closes#36464, backports#36758 to 8.0

Description
When generating the shaper (code which reads back results from the database), the current logic wrongly captures the current query logger (which is a scoped service); this means that whatever logger is in use when the query is first compiled gets referenced from the shaper, and stored in our singleton query cache potentially forever (or until evicted). The logger has references ultimately leading to the EF change tracker and through it, meaning that these user objects are kept alive forever (a form of leak).

Customer impact
With specific usage, arbitrary large user objects may be kept alive forever, and never garbage-collected. In addition, the wrong query logger instance may get used (the one from when the query was first compiled, instead of the current one for the query being executed), which could lead to incorrect logging.

We have performed patch servicing for this kind of bug before (because of the leak potential).

How found
Customer report

Regression
Yes, from EF 7 to EF 8; introduced in#31100.

Testing
This is unfortunately difficult/possible to test automatically, as it's about an unwanted reference in the shaper keeping objects alive. Tested manually to ensure that the shaper no longer contains the reference.

Risk
Low. The change is simple, and we have ample code coverage for the affected codepaths; quirk added.

…6758)Instead of closing over the current scoped logger, causing a leak.Closesdotnet#36464(cherry picked from commitb7996be)
@rojiroji requested a review froma teamSeptember 14, 2025 07:43
@rojiroji merged commitd574040 intodotnet:release/8.0-stagingSep 15, 2025
7 checks passed
@rojiroji deleted the JsonLeak8 branchSeptember 15, 2025 07:06
This was referencedOct 14, 2025
This was referencedNov 24, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@cincuranetcincuranetcincuranet approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@roji@cincuranet

[8]ページ先頭

©2009-2025 Movatter.jp