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

Add support for SqlConnectionOverrides for OpenAsync() API #2433

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cheenamalhotra
Copy link
Member

@cheenamalhotra cheenamalhotra commented Mar 27, 2024

As the name suggests, introduces new API:

public Task SqlConnection.OpenAsync(SqlConnectionOverrides overrides, CancellationToken cancellationToken);

Previously, we skipped addiing overrides to OpenAsync in PR #463 due to no transient fault handling, but with recent PR #1983 we now enable transient fault handling by default for OpenAsync() too.

To support fail fast behavior in OpenAsync(), we need to allow passing SqlConnectionOverrides in OpenAsync() too.

Additional context:
dotnet/efcore#33399
#29

..\doc\snippets\Microsoft.Data.Sql\SqlDataSourceEnumerator.xml = ..\doc\snippets\Microsoft.Data.Sql\SqlDataSourceEnumerator.xml
..\doc\snippets\Microsoft.Data.Sql\SqlNotificationRequest.xml = ..\doc\snippets\Microsoft.Data.Sql\SqlNotificationRequest.xml
Copy link
Member

Choose a reason for hiding this comment

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

Could you revert the irrelevant changes in the solution file, please?

{
SqlConnectionStringBuilder connectionStringBuilder = new(DataTestUtility.TCPConnectionString)
{
InitialCatalog = "DoesNotExist0982532435423",
Copy link
Member

Choose a reason for hiding this comment

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

It's less likely to exist.

Suggested change
InitialCatalog = "DoesNotExist0982532435423",
InitialCatalog = DataTestUtility.GetUniqueNameForSqlServer("DoesNotExist", false),

await Assert.ThrowsAsync<SqlException>(async () => await sqlConnection.OpenAsync(CancellationToken.None));
timer.Stop();
duration = timer.Elapsed;
Assert.True(duration.Seconds > 5, $"Connection OpenAsync() with retries took less time than expected. Expect > 5 sec with transient fault handling. Took {duration.Seconds} sec."); // sqlConnection.OpenAsync();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Assert.True(duration.Seconds > 5, $"Connection OpenAsync() with retries took less time than expected. Expect > 5 sec with transient fault handling. Took {duration.Seconds} sec."); // sqlConnection.OpenAsync();
Assert.True(duration.Seconds > 5, $"Connection OpenAsync() with retries took less time than expected. Expect > 5 sec with transient fault handling. Took {duration.Seconds} sec.");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 Public API Use this label for new API additions to the driver.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants