Skip to content

[release/6.0] Clear reference to DbDataReader from RelationalDataReader - #29005

Merged
wtgodbe merged 1 commit into
dotnet:release/6.0from
roji:ReaderReference6.0
Oct 4, 2022
Merged

[release/6.0] Clear reference to DbDataReader from RelationalDataReader#29005
wtgodbe merged 1 commit into
dotnet:release/6.0from
roji:ReaderReference6.0

Conversation

@roji

@roji roji commented Sep 7, 2022

Copy link
Copy Markdown
Member

Fixes #28988

Description

In EF Core 6.0, we started recycling RelationalDataReader instances across RelationalCommand invocations, to optimize the query pipeline and cut down on needless allocations. However, the RelationalDataReader retains its reference to its DbDataReader until a new query is executed; if a BufferedDataReader is used, that can mean needlessly preventing garbage collection of lots of all query data. This is exarcebated by context pooling (where the context is kept around for much longer).

Customer impact

Significantly increased memory usage when a retrying execution is used, context pooling is activated and large results are queries from the database.

How found

Customer reported on 6.0

Regression

Yes, in 6.0.

Testing

Added a test.

Risk

Low.

This is port of #28989 which was already merged for 7.0.

@roji roji changed the title Clear reference to DbDataReader from RelationalDataReader (#28989) [release/6.0] Clear reference to DbDataReader from RelationalDataReader Sep 7, 2022
@rbhanda rbhanda added this to the 6.0.11 milestone Sep 20, 2022
@wtgodbe
wtgodbe merged commit bbd8552 into dotnet:release/6.0 Oct 4, 2022
@ajcvickers ajcvickers removed this from the 6.0.11 milestone Oct 5, 2022
@roji
roji deleted the ReaderReference6.0 branch June 13, 2025 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants