-
Notifications
You must be signed in to change notification settings - Fork 317
Description
While investigating other issues I’ve found probably few hard to reproduce issue.
I haven’t seen them happening, but I’ve seen several issues which are claimed as hard to reproduce/happens under heavy load, so may be it could help there. In original PR (where code has been introduced) that was mentioned also.
This block accessing sockets array
SqlClient/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
Line 341 in 8ad8da6
| if (sockets[i] != null && !sockets[i].Connected) |
is not synchronized with this one
SqlClient/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
Line 368 in 8ad8da6
| if (sockets[i] != null) // sockets[i] can be null if cancel callback is executed during connect() |
The following order seems is possible:
- if (sockets[i] != null && !sockets[i].Connected) is true
- if (sockets[i] != null) gives true
- if (sockets[i].Connected) gives true
- sockets[i].Dispose();
- availableSocket = sockets[i];
- break; return availableSocket;
In this case socket is first returned and then at random time disposed while being used (user does not receive any exceptions, connection just disposes).
But there are also many hard investigate synchronization/exceptions things there. I think may be that entire file and related should be checked/reviewed again.