Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct timeout remarks for SqlClient async command methods #3343

Merged
merged 1 commit into from
Nov 26, 2019

Conversation

roji
Copy link
Member

@roji roji commented Oct 14, 2019

After investigating npgsql/npgsql#2457, it turns out that SqlCommand.CommandTimeout works well with async methods, just not with the old-style pre-async/await Begin* methods. However, the documentation remarks still indicate that timeouts aren't supported with any async SqlClient APIs.

@roji roji requested a review from stevestein as a code owner October 14, 2019 11:15
@roji
Copy link
Member Author

roji commented Oct 14, 2019

@roji
Copy link
Member Author

roji commented Oct 14, 2019

Test used to confirm the behavior:

using var conn = new SqlConnection("...");
using var cmd = new SqlCommand("WAITFOR DELAY '00:00:05'", conn) { CommandTimeout = 1 };
conn.Open();

// Sync: times out
cmd.ExecuteNonQuery();

// Async: times out
await cmd.ExecuteNonQueryAsync();

// Old-style async: does not time out
var asyncResult = cmd.BeginExecuteNonQuery();
asyncResult.AsyncWaitHandle.WaitOne();
var result = cmd.EndExecuteNonQuery(asyncResult);

@roji
Copy link
Member Author

roji commented Oct 14, 2019

Corresponding PR for Microsoft.Data.SqlClient: dotnet/SqlClient#264

@roji
Copy link
Member Author

roji commented Oct 24, 2019

@carlossanlop the SqlClient people have approved this, and the corresponding changes have already been merged in https://github.com/dotnet/sqlclient. Can someone sign off on this from your side as well?

@carlossanlop
Copy link
Member

@BillWagner @mairaw can someone in your team please take a look?

@mairaw mairaw self-requested a review October 24, 2019 17:37
@mairaw
Copy link
Contributor

mairaw commented Oct 24, 2019

Sure, I'll review this one. @stevestein you should keep an eye on PRs assigned to you for review for the System.Data space.

@roji roji force-pushed the SqlClientAsyncTimeout branch from ef0106e to dc58aca Compare October 25, 2019 08:06
@roji roji requested a review from mairaw October 26, 2019 08:36
@roji
Copy link
Member Author

roji commented Nov 4, 2019

ping, this is still waiting validation.

Copy link
Member

@carlossanlop carlossanlop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay @roji. Thanks for making this change. It looks good. I'll merge it.

@carlossanlop carlossanlop merged commit b2dfc95 into dotnet:master Nov 26, 2019
@roji
Copy link
Member Author

roji commented Nov 26, 2019

No problem at all, thanks @carlossanlop!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants