-
Notifications
You must be signed in to change notification settings - Fork 295
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
SqlClient ManualTest MARSSyncTimeoutTest fails in managed mode #108
SqlClient ManualTest MARSSyncTimeoutTest fails in managed mode #108
Comments
To be clear, I'm happy to fix this and run it through the required testing then PR if we can agree what the fix should be. |
This looked simple but quickly went down a rabbit hole filled with angry badgers. If the assert is removed the call to |
It looks like any timeout in managed mode will fail at this assert. It isn't limited to mars. Once the timeout occurs the socket closing causes the stack trace seen above which causes the failure mode. I think this needs to be handled before it bubbles up to the HandleReceiveError layer because at that point the error code is lost and it becomes just an empty packet, the possible association with the closing of the socket is lost. |
The manual tests affected by this are: ConnectionPoolTest.ConnectionPool_NonMars |
@Wraith2 we are not sure what the potential fix for this issue is right now. If you have time to investigate, please feel free to do so and let us know what any potential options are, otherwise we will come back to this issue in the future. |
I think the best thing might be to remove the check which is asserting. If you run the tests in release mode everything behaves as expected and the logic for the assertion is of dubious quality in my opinion, |
I've been looking at this again and I've changed my thinking. I think the problem is that in the SNIMarsHandle when it receives an error it attempts to process the packet indiscriminately by passing it to the callback. In the case where there is no packet contents this is the wrong thing to do. I currently think that the right thing to do is to add in a The code in this are is complex and filled with async. While I can try this and may not see any problems I'd like some feedback on the logic and feeling of it from people with experience in the networking side before I try. /cc tagging new people @tarikulsabbir @Gary-Zh |
Reopening as @Wraith2 indicated that the issue has not been solved by the PRs. |
@Wraith2 If you have time to look at this, great. Otherwise we will work on it when we have bandwidth. Thanks! |
I posted a couple of solutions and discussed it at some length with @saurabh500 in their discussions. This is something we've discussed offline and it's waiting for him to get chance to investigate a fix which fits better with the architecture.
This is the main blocker on continued improvements to the managed implementation because it prevents many important tests from running. |
When using the managed sni implementation in SqlClient the MARS related test MARSSyncTimeoutTest fails with an assertion in debug mode. This may not cause a problem in release builds because there are sufficient checks in the method body to prevent errors occurring or bubbling up to the user. I suspect that the assertion is incorrect but it needs scrutiny from someone more familiar with the library.
To reproduce on windows. Checkout master, change UseManagedSNI to true. Build and run manual tests, or run the specific named test If you know the commandline incantation required.
It is happens when the socket for the connection is closed by the timeout in the test, in this case there is no data array in the
SNIPacket
and that means that the assertion on managed CheckPacket returns false indicating the packet is invalid by asking the packet if it's invalid, which checks the data. The native CheckPacket doesn't check the contents of the packet, only that it is a pointer to a valid packet structure which is a slightly different check to the managed version, the managed version requires that the packet be non-null and that it contain a valid array which is the cause of the problem./cc @afsanehr @saurabh500 @keeratsingh
The text was updated successfully, but these errors were encountered: