You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Some sort of infinite loop in SqlDataReader.ReadAsync() ? #1058
A customer reported that reading a single row from the database caused the process to consume 5 GB of memory and crash.
The row beeing read has very few columns
One of the columns is an xml-column
The problem only occurs when the XML-column has large contents (the customer can reproduce with 7MB xml)
Apparently Read() works fine, the problem only occurs with ReadAsync()
Attaching screenshot made by customer. I watched this over teams, and this is not the production error, but reproducing using a console app. The call hangs, and memory keeps building.
I'm aware ReadAsync() is extremely slow, we have been looking into it's performance issues as well.. but wasn't aware if it could crash like that, will investigate and get back to you.
In the meantime, please use Read() as a workaround.
The issue describes SqlDataReader.ReadAsync() entering what appears to be an unbounded loop/severe memory growth (~5 GB) when reading a single row containing a large XML column (~7 MB), while the synchronous Read() path works correctly. This points to inefficient buffering/allocation behavior in the async large-value (XML/text) reading path in TdsParser/SqlSequentialTextReader-related code, consistent with the broader async large-object performance problems tracked in the parent issue #593 and related issue #1877 (O(N^2) performance reading XML with SequentialAccess). Given the reported crash/OOM-class impact on production servers (per a 2025 follow-up comment), this should be treated as P1 pending reproduction, since it can bring down a service, though currently it lacks environment specifics to confirm it still reproduces on a supported version.
Next Steps
@christian-ruud (or any current reproducer), please provide: exact Microsoft.Data.SqlClient version, .NET target framework, SQL Server version, and Operating System so we can attempt to reproduce on currently supported versions.
Since multiple related/duplicate issues exist, consider consolidating or cross-linking them to avoid duplicated investigation effort.
Note: This triage summary is auto-generated by an AI agent. The analysis and suggestions above have not been verified by a human maintainer. Please treat as preliminary guidance only.
Activity
cheenamalhotra commentedon May 3, 2021
Hi @christian-ruud
I'm aware
ReadAsync()is extremely slow, we have been looking into it's performance issues as well.. but wasn't aware if it could crash like that, will investigate and get back to you.In the meantime, please use
Read()as a workaround.christian-ruud commentedon May 3, 2021
MichelZ commentedon Nov 23, 2024
Also related to #593
backstromjoel commentedon Mar 28, 2025
This just took down a few of our servers 😓
ErikEJ commentedon Mar 28, 2025
@backstromjoel using which driver version??
priyankatiwari08 commentedon Sep 17, 2026
/triage
github-actions commentedon Sep 17, 2026
🔍 Triage Summary (on-demand re-triage)
Area\AsyncAnalysis
The issue describes
SqlDataReader.ReadAsync()entering what appears to be an unbounded loop/severe memory growth (~5 GB) when reading a single row containing a large XML column (~7 MB), while the synchronousRead()path works correctly. This points to inefficient buffering/allocation behavior in the async large-value (XML/text) reading path inTdsParser/SqlSequentialTextReader-related code, consistent with the broader async large-object performance problems tracked in the parent issue #593 and related issue #1877 (O(N^2) performance reading XML withSequentialAccess). Given the reported crash/OOM-class impact on production servers (per a 2025 follow-up comment), this should be treated as P1 pending reproduction, since it can bring down a service, though currently it lacks environment specifics to confirm it still reproduces on a supported version.Next Steps
SqlDataReader.ReadAsync()and the async XML/large-value plumbing (e.g.,TdsParserStateObject,SqlSequentialTextReader,SqlSequentialStream) for unbounded buffer growth or repeated re-allocation when consuming large XML values asynchronously, and to compare against the synchronousRead()code path which does not exhibit the issue.