Skip to content

Fixes "InvalidOperationException" errors by performing async operations in SemaphoreSlim - #796

Merged
cheenamalhotra merged 20 commits into
dotnet:masterfrom
cheenamalhotra:fix459
Nov 19, 2020
Merged

Fixes "InvalidOperationException" errors by performing async operations in SemaphoreSlim#796
cheenamalhotra merged 20 commits into
dotnet:masterfrom
cheenamalhotra:fix459

Conversation

@cheenamalhotra

@cheenamalhotracheenamalhotra commented Nov 13, 2020

Copy link
Copy Markdown
Member

Fixes#459#54#786#792
Rework over PR #579 with helpful ideas from @roji and @DavoudEshtehari

This PR fixes the issue where below exception would occur randomly due to SslStream.WriteAsync collisions.

System.InvalidOperationException: Invalid operation. The connection is closed.
at Microsoft.Data.SqlClient.TdsParserStateObject.WritePacket(Byte flushMode, Boolean canAccumulate)

The design change introduces use of SemaphoreSlim with SNISslStream and SNINetworkStream overrides to ensure only 1 task is allowed to read/write to stream asynchronously at a time.

Not fixed in this issue

@cheenamalhotracheenamalhotra changed the title Fixes "InvalidOperationException" errors by performing async write operations in Semaphore Concurrent QueueFixes "InvalidOperationException" errors by performing async operations in Semaphore Concurrent QueueNov 13, 2020
@cheenamalhotracheenamalhotra added the Performance 📈 Issues that are targeted to performance improvements. label Nov 17, 2020
@cheenamalhotra
cheenamalhotraforce-pushed the fix459 branch 2 times, most recently from df81c95 to 2d69793CompareNovember 18, 2020 23:59
@cheenamalhotra
cheenamalhotra merged commit cde615e into dotnet:masterNov 19, 2020
@cheenamalhotra
cheenamalhotra deleted the fix459 branch April 1, 2026 16:21
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Performance 📈Issues that are targeted to performance improvements.

Projects

None yet

7 participants

@cheenamalhotra@roji@martyt@Wraith2@David-Engel@karinazhou@DavoudEshtehari