-
Notifications
You must be signed in to change notification settings - Fork 286
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 | Fix possible server connection leak if an exception occurs in pooling layer #890
Conversation
c881b91
to
8fb621f
Compare
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs
Outdated
Show resolved
Hide resolved
This change can be tested using the TestTdeServer and injecting transient failures SqlClient/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionBasicTests.cs Line 18 in 9e3f0d6
Another example of the usage of server is at SqlClient/src/Microsoft.Data.SqlClient/tests/ManualTests/TracingTests/DiagnosticTest.cs Line 701 in 6a9e4f1
|
LGTM. |
/azp run CI-BuildNPack |
Azure Pipelines successfully started running 1 pipeline(s). |
Hi @saurabh500 I've added the test case and I can also reproduce In order to capture the leaked connection, you'll need to add breakpoint in exception handling logic in the test and capture heap snapshot. Navigating through Heap Snashot you will come across 1 instance of |
This PR is additional fix for consequences of error
Internal .NET Framework Data Provider error 6.
that is thrown fromDbConnectionPool.CreateObject
method when something goes wrong in Pooling layer.Continued investigations over original issue that was fixed by #637 led to figuring out that the catch blocks in this method simply set
newObj
tonull
, leaking resources and TDS connections on server, that can only be garbage collected on client when server drops them.This causes expensive connection leaks on server, and issue exists in System.Data.SqlClient and Microsoft.Data.SqlClient (<2.0.1).
In Microsoft.Data.SqlClient we fixed this issue with PR #638 and #637, this PR is also a fix that ensures resources are cleaned properly in any similar future events.