Skip to content

Some sort of infinite loop in SqlDataReader.ReadAsync() ? #1058

Open

Description

@christian-ruud

A customer reported that reading a single row from the database caused the process to consume 5 GB of memory and crash.

  1. The row beeing read has very few columns
  2. One of the columns is an xml-column
  3. The problem only occurs when the XML-column has large contents (the customer can reproduce with 7MB xml)
  4. 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.

ReadAsync-Issue

Activity

  1. cheenamalhotra commented on May 3, 2021

    @cheenamalhotra
    Member

    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.

  2. christian-ruud commented on May 3, 2021

    @christian-ruud
    Author
  3. MichelZ commented on Nov 23, 2024

    @MichelZ
    Contributor

    Also related to #593

  4. backstromjoel commented on Mar 28, 2025

    @backstromjoel

    This just took down a few of our servers 😓

  5. ErikEJ commented on Mar 28, 2025

    @ErikEJ
    Contributor

    @backstromjoel using which driver version??

  6. moved this from To triage to Backlog in SqlClient Boardon Dec 23, 2025
  7. priyankatiwari08 commented on Sep 17, 2026

    @priyankatiwari08
    Contributor

    /triage

  8. github-actions commented on Sep 17, 2026

    @github-actions

    🔍 Triage Summary (on-demand re-triage)

    Check Result
    Issue type Bug
    Environment ⚠️ Missing: SqlClient version, .NET target framework, SQL Server version, Operating System
    Area Area\Async
    Duplicates Potentially related: #593, #1877, #3274
    Regression Not indicated

    Analysis

    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

    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.

    Generated by SqlClient Issue Auto-Triage for #1058 · copilot · auto · 49.2 AIC · ⌖ 13.2 AIC · ⊞ 11.9K · ◷

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions