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

Fix | FailoverPartner key check in SqlConnectionPoolGroupProviderInfo #1614

Conversation

lcheunglci
Copy link
Contributor

Relates to issue #1594 and #1613 , I think we can either do a check if the key exists first before retrieving the value from the SqlConnectionString using the Dictionary get operator[] or use TryGetValue with null as the default value if that's the expected behaviour because I don't think it's obvious that we need to specify FailOverPartner set it to an empty string.

@lcheunglci lcheunglci changed the title Fix | FailoverPartner key Fix | FailoverPartner key check in SqlConnectionPoolGroupProviderInfo May 13, 2022
@ErikEJ
Copy link
Contributor

ErikEJ commented May 14, 2022

Wonder if a test is possible - why does this crop up?

@lcheunglci
Copy link
Contributor Author

I think it depends on how the Sql Server is configured, so a special test agent/vm might be required in the build/test pipeline to be able to verify this properly.

@DavoudEshtehari DavoudEshtehari added this to the 5.0.0 milestone Jul 12, 2022
@@ -104,7 +104,8 @@ private PermissionSet CreateFailoverPermission(SqlConnectionString userConnectio
// the server, we will use that name over what was specified
// in the original connection string.

if (null == userConnectionOptions[SqlConnectionString.KEY.FailoverPartner])
if (userConnectionOptions.ContainsKey(SqlConnectionString.KEY.FailoverPartner) &&
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious how a connection without AG setup can reach this line! I tried locally (Win 10) and in Win Server 2019, but neither got to this line.
Could you reproduce it?

Choose a reason for hiding this comment

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

At least in #1594, the data source was an AG. It's not specified in #1613 whether the data source was an AG.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think the issue occurs without a AG setup. I tried locally prior to this and wasn't able to reproduce.

Choose a reason for hiding this comment

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

I have just experienced this issue in a non-AG setup.

@DavoudEshtehari
Copy link
Member

DavoudEshtehari commented Jul 19, 2022

/azp run CI-SqlClient

@azure-pipelines
Copy link

You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list.

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@codecov
Copy link

codecov bot commented Jul 19, 2022

Codecov Report

Merging #1614 (cd6c8ee) into main (4e3aa5e) will decrease coverage by 0.74%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main    #1614      +/-   ##
==========================================
- Coverage   71.54%   70.80%   -0.75%     
==========================================
  Files         291      293       +2     
  Lines       61241    64256    +3015     
==========================================
+ Hits        43817    45494    +1677     
- Misses      17424    18762    +1338     
Flag Coverage Δ
addons 92.38% <ø> (ø)
netcore 73.80% <ø> (-1.29%) ⬇️
netfx 69.15% <0.00%> (-0.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ta/SqlClient/SqlConnectionPoolGroupProviderInfo.cs 42.50% <0.00%> (-1.09%) ⬇️
...ata/SqlClient/SqlConnectionTimeoutErrorInternal.cs 30.35% <0.00%> (-21.43%) ⬇️
...src/Microsoft/Data/SqlClient/SqlMetadataFactory.cs 81.66% <0.00%> (-10.84%) ⬇️
...ActiveDirectoryAuthenticationTimeoutRetryHelper.cs 56.81% <0.00%> (-6.82%) ⬇️
...rc/Microsoft/Data/SqlClient/SQLFallbackDNSCache.cs 90.62% <0.00%> (-6.25%) ⬇️
.../netcore/src/Microsoft/Data/SqlClient/TdsParser.cs 68.35% <0.00%> (-5.45%) ⬇️
...SqlClient/src/Microsoft/Data/SqlClient/TdsEnums.cs 87.56% <0.00%> (-5.12%) ⬇️
.../src/Microsoft/Data/SqlTypes/SqlTypeWorkarounds.cs 71.42% <0.00%> (-4.77%) ⬇️
.../src/Microsoft/Data/SqlClient/SNI/SNIMarsHandle.cs 87.89% <0.00%> (-4.49%) ⬇️
...nt/src/Microsoft/Data/ProviderBase/TimeoutTimer.cs 71.42% <0.00%> (-3.58%) ⬇️
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4e3aa5e...cd6c8ee. Read the comment docs.

@gregpakes
Copy link

Is this getting patched into v4?

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.

8 participants