-
Notifications
You must be signed in to change notification settings - Fork 312
Refactor for modular connection pool #3199
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
Conversation
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3199 +/- ##
==========================================
- Coverage 72.89% 65.96% -6.94%
==========================================
Files 288 283 -5
Lines 59246 59209 -37
==========================================
- Hits 43190 39055 -4135
- Misses 16056 20154 +4098
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
PR Overview
This PR refactors the connection pool implementation to be more modular by introducing an abstract DbConnectionPool class and moving pooling-related classes into the Microsoft.Data.SqlClient.ConnectionPool namespace.
- Introduces a new abstract class (DbConnectionPool) that captures the current connection pool API.
- Migrates several classes from Microsoft.Data.ProviderBase to Microsoft.Data.SqlClient.ConnectionPool.
- Updates pool instantiation in DbConnectionPoolGroup to use WaitHandleDbConnectionPool, supporting modular and swappable implementations.
Reviewed Changes
File | Description |
---|---|
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPool.cs | Adds a new abstract base class for connection pooling API. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolCounters.netfx.cs | Updates the namespace to the new connection pool namespace. |
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs | Adapts references from the old provider base pool group to the new connection pool group. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolIdentity.Unix.cs | Updates namespace from ProviderBase to SqlClient.ConnectionPool. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolAuthenticationContextKey.cs | Updates namespace from ProviderBase to SqlClient.ConnectionPool. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolGroupProviderInfo.cs | Updates namespace from ProviderBase to SqlClient.ConnectionPool. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolAuthenticationContext.cs | Updates namespace from ProviderBase to SqlClient.ConnectionPool. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolGroup.cs | Modifies pool instantiation to use WaitHandleDbConnectionPool. |
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs | Incorporates the new connection pool namespace in factory logic. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs | Updates pool group references to use the new connection pool namespace. |
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs | Updates pool group references to use the new connection pool namespace. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs | Adapts using statements to include the new connection pool namespace. |
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs | Updates namespace references accordingly. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs | Updates namespace to use the new connection pool namespace. |
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs | Updates namespace to include the new connection pool namespace. |
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs | Updates namespace imports accordingly. |
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs | Updates namespace imports accordingly. |
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs | Updates namespace imports accordingly. |
Copilot reviewed 33 out of 33 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolGroup.cs:190
- Please ensure that the new WaitHandleDbConnectionPool implementation is thoroughly tested to validate its initialization, cleanup, and overall behavior in the connection pool lifecycle.
DbConnectionPool newPool = new WaitHandleDbConnectionPool(connectionFactory, this, currentIdentity, connectionPoolProviderInfo);
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.
Overall I like these changes. Mostly stylistic changes I'm requesting, a couple bigger questions around what the longer term plan is.
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPool.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPool.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPool.cs
Outdated
Show resolved
Hide resolved
...oft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/WaitHandleDbConnectionPool.cs
Outdated
Show resolved
Hide resolved
...oft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/WaitHandleDbConnectionPool.cs
Outdated
Show resolved
Hide resolved
...oft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/WaitHandleDbConnectionPool.cs
Outdated
Show resolved
Hide resolved
...oft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/WaitHandleDbConnectionPool.cs
Outdated
Show resolved
Hide resolved
...soft.Data.SqlClient/tests/ManualTests/SQL/Common/SystemDataInternals/ConnectionPoolHelper.cs
Show resolved
Hide resolved
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.
Looks much better now, thanks!
Introduces an abstract class to capture the API of the current connection pool implementation. Gathers pooling related classes into a single namespace (Microsoft.Data.SqlClient.ConnectionPool) and folder. These changes set the stage for swappable connection pool implementations. Targeting main because these are good standalone changes for code cleanliness. Future changes will target a feature branch.
This work is tracking against #25
PoolBlockingPeriod is not moved because it is public. Moving it's location/namespace would be a breaking API change. It may still make sense to switch its namespace if this can go in with a major version bump.