Skip to content

SqlClient gets stuck asynchronously reading string values in certain conditions #3504

@Suchiman

Description

@Suchiman

Describe the bug

On a highly specific arrangement of data, SqlClient will be stuck in a forever loop in TryReadPlpUnicodeChars, attempting to asynchronously read data.

To reproduce

This issue seems to be latency sensitive as well so using a remote database like SQL Azure is advised.

Setup a database and test project as described in the following gist:
https://gist.github.com/Suchiman/1b70ab4d8b549b5c647f495533ee39c3

If you run the test project, it will print:

Starting query
Retrieved records in 00:00:00.5410259
Starting query

and now the program is forever stuck on the second iteration.

Expected behavior

Will continously print

Starting query
Retrieved records in ...

without ever getting stuck

Further technical details

Microsoft.Data.SqlClient version: 6.1.0-preview2.25178.5
.NET target: .NET 9
SQL Server version: SQL Azure / SQL Server 2022
Operating system: App Service / Windows 11

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions