Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Remove IncrementPendingCallback from MARS sync reads #28427

Merged
merged 2 commits into from
Mar 23, 2018

Conversation

saurabh500
Copy link
Contributor

While looking into the usage of the LongRunning option usage with SqlClient in the issue https://github.com/dotnet/corefx/issues/19836 it seemed that there is a particular order of MARS execution which can result in hangs (for which the LongRunning options was originally introduced)

A hang in MARS is happening still when a sync execution is followed by an async execution this can be easily reproduced if the following two tests are executed one after another.

System.Data.SqlClient.ManualTesting.Tests.CommandCancelTest.TimeoutCancel
System.Data.SqlClient.ManualTesting.Tests.CommandCancelTest.PlainCancelTestAsync

In case of Mars, SqlClient increments the pending counter by one for sync reads, which is then checked in Async operations at https://github.com/dotnet/corefx/blob/master/src/System.Data.SqlClient/src/System/Data/SqlClient/TdsParserStateObject.cs#L2742 and the pending Callback is >=2 causing the Task result to not be set at all. This results in a hang while executing a MARS async operation since the Task result or error will never be set.

Incrementing the pending callbacks were always made for Async operations and in case of MARS, SqlClient was incrementing this counter for sync reads as well.

The code review has two commits

  1. Removes the call to the IncrementPendingCallbacks
  2. Removes the flag which signals the method that MARS is on, and should increment the counter, since the flag is not needed anymore.

We had added the LongRunning option to MARS async Network API calls because the EF tests were hanging. Given that there is a specific pattern in which this hang can be reproed consistently, LongRunning flag on task continuation may not have been solving any problems for us. I need to confirm that by running EF tests by removing LongRunning continuation option.

@saurabh500 saurabh500 merged commit 4c1704f into dotnet:master Mar 23, 2018
@karelz karelz added this to the 2.1.0 milestone Mar 27, 2018
@saurabh500 saurabh500 deleted the marsPendingCounter branch April 9, 2019 22:33
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…8427)

* Don't increment Pending callback on Mars sync reads

* Remove extra function parameter


Commit migrated from dotnet/corefx@4c1704f
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants