-
Notifications
You must be signed in to change notification settings - Fork 294
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 | SqlClient-826 Missed synchronization #1029
Conversation
SqlClient-826 Missed synchronization Additionally: * Exceptions swallowing removed to satisfy CA1031 https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1031 * InternalException refactored to satisfy ca1032 https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1032 (Best practices https://docs.microsoft.com/en-us/dotnet/standard/exceptions/best-practices-for-exceptions#include-three-constructors-in-custom-exception-classes ) * InternalException constructor has been changed to public as class is not marked as sealed.
@cheenamalhotra I can't add label "Managed SNI". Could you, please? This comment can be removed then |
# Conflicts: # src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
@JRahnama I've took into account that PR and merged it. However I allowed myself to slightly fix that PR while keeping the idea of it. |
@jinek thanks for contributing into this repository, We have a release scheduled for this week and pretty busy with release activities. We will get back to this next week when we have more time. |
* Complexity of array enumeration changed: n*n in worst case with 2n * Long to int (timeout) is now checked to avoid timeout errors
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
Outdated
Show resolved
Hide resolved
# Conflicts: # src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
I've updated the PR, @DavoudEshtehari .
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran the failed pipelines one more time, and the result remained the same. The reason for these failures as I know is the execution time exceeds the allowed 1 hour. First of all, we need to verify in which situations it happens; Maybe running a benchmark test could help us too!
- Here additional improvement can be done. For infinite timeout case we can avoid exception throwing which would give small performance boost, but code would become more complex. Should I add the code for infinite timeout case (it's about 3 additional if blocks)?
Feel free to add your suggested change for further discussions.
- I've removed the check of Dns.GetHostAddresses for returning null as seems it does not ever return null. However it's not declared by the documentation of the method and I don't understand where it is supposed always return an array or no. Should I brind back the code considering it returning null? (probably just adding one redundent if block)
Right, I checked the source code of the Dns.GetHostAddresses, it won't return null
in case of a free-error execution. So, as you mentioned, null-checking is not necessary.
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
Outdated
Show resolved
Hide resolved
I have checked the issue: here the connection timeout is set to almost 3 hours (10000 seconds) : Line 298 in d65dc86
Same time SqlInternalConnectionTds runs retry for all random errors: Line 1618 in 2ddf3a3
In my case the error is "Arithmetic operation resulted in an overflow." because 10000 seconds can not be passed to Socket.Select as it requires the value in microseconds int32: https://github.com/dotnet/runtime/blob/9ce467fe6164e781b67897615ff7dd01820084ff/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs#L2199 @DavoudEshtehari |
Also fixes this: #583 |
Looking at the SocketPal.Select API, it seems they could do well with a There's also an open API Proposal from 6 years ago, you might want to ask dotnet/runtime teams to resurrect: dotnet/runtime#14336 Connection timeout cannot be limited as that would be a major issue for customer applications (we know of) running high loads of work and setting timeout to as long as 2 hours. |
Right right, but all this options are time consuming? |
# Conflicts: # src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1029 +/- ##
==========================================
- Coverage 70.80% 70.63% -0.18%
==========================================
Files 305 305
Lines 61795 61807 +12
==========================================
- Hits 43756 43657 -99
- Misses 18039 18150 +111
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Common/src/System/Net/InternalException.cs
Outdated
Show resolved
Hide resolved
…/InternalException.cs Co-authored-by: DavoudEshtehari <61173489+DavoudEshtehari@users.noreply.github.com>
…ient\SNI\SNITcpHandle.cs(356,82): Error CS1574: XML comment has cref attribute 'ipPreference' that could not be resolved"
reorder & xml doc
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
Outdated
Show resolved
Hide resolved
…ent/SNI/SNITcpHandle.cs Co-authored-by: DavoudEshtehari <61173489+DavoudEshtehari@users.noreply.github.com>
…ent/SNI/SNITcpHandle.cs Co-authored-by: DavoudEshtehari <61173489+DavoudEshtehari@users.noreply.github.com>
…ent/SNI/SNITcpHandle.cs Co-authored-by: DavoudEshtehari <61173489+DavoudEshtehari@users.noreply.github.com>
…ent/SNI/SNITcpHandle.cs Co-authored-by: DavoudEshtehari <61173489+DavoudEshtehari@users.noreply.github.com>
…ent/SNI/SNITcpHandle.cs Co-authored-by: DavoudEshtehari <61173489+DavoudEshtehari@users.noreply.github.com>
…ent/SNI/SNITcpHandle.cs Co-authored-by: DavoudEshtehari <61173489+DavoudEshtehari@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done 🎉
Fixes #826
Internal method SNITCPHandle.Connect now uses Socket.Select to connect the socket with a timeout or without
Additionally: