Skip to content

Commit 565cf6a

Browse files
author
Tobias Jamin
committed
Switch SqlDataReader.ReadAsync/SqlDataReader.GetFieldValueAsync to synchronous versions in SqlSessionStateProvicerAsync because there exists a performance issue with reading large data asynchronously (dotnet/SqlClient#593)
1 parent 97428df commit 565cf6a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/SqlSessionStateProviderAsync/SqlSessionStateRepository.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,11 +492,13 @@ public async Task<SessionItem> GetSessionStateItemAsync(string id, bool exclusiv
492492
{
493493
using (var reader = await SqlSessionStateRepositoryUtil.SqlExecuteReaderWithRetryAsync(connection, cmd, CanRetryAsync))
494494
{
495-
if (await reader.ReadAsync())
495+
// use the synchronous versions of Read and GetFieldValue because of performance issues with
496+
// large data described here: https://github.com/dotnet/SqlClient/issues/593
497+
if (await reader.Read())
496498
{
497499
// Varbinary(max) should not be returned in an output parameter
498500
// Read the returned dataset consisting of SessionItemLong if found
499-
buf = await reader.GetFieldValueAsync<byte[]>(0);
501+
buf = await reader.GetFieldValue<byte[]>(0);
500502
}
501503
}
502504

0 commit comments

Comments
 (0)