Skip to content

New pool scaffolding #3352

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

Merged
merged 19 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@
<Compile Include="$(CommonSourceRoot)\Microsoft\Data\ProviderBase\DbConnectionFactory.cs">
<Link>Microsoft\Data\ProviderBase\DbConnectionFactory.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\ConnectionPool\ChannelDbConnectionPool.cs">
<Link>Microsoft\Data\SqlClient\ConnectionPool\ChannelDbConnectionPool.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolAuthenticationContext.cs">
<Link>Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolAuthenticationContext.cs</Link>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,6 @@
<Compile Include="$(CommonSourceRoot)Microsoft\Data\ProviderBase\DbConnectionInternal.cs">
<Link>Microsoft\Data\ProviderBase\DbConnectionInternal.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\ConnectionPool\ChannelDbConnectionPool.cs">
<Link>Microsoft\Data\SqlClient\ConnectionPool\ChannelDbConnectionPool.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolAuthenticationContext.cs">
<Link>Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolAuthenticationContext.cs</Link>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ private void PruneConnectionPoolGroups(object state)
if (0 == pool.Count)
{
_poolsToRelease.Remove(pool);
SqlClientEventSource.Log.TryAdvancedTraceEvent("<prov.DbConnectionFactory.PruneConnectionPoolGroups|RES|INFO|CPOOL> {0}, ReleasePool={1}", ObjectID, pool.ObjectId);
SqlClientEventSource.Log.TryAdvancedTraceEvent("<prov.DbConnectionFactory.PruneConnectionPoolGroups|RES|INFO|CPOOL> {0}, ReleasePool={1}", ObjectID, pool.Id);

SqlClientEventSource.Metrics.ExitInactiveConnectionPool();
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using Microsoft.Data.Common;
using Microsoft.Data.ProviderBase;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -189,8 +190,7 @@ internal IDbConnectionPool GetConnectionPool(DbConnectionFactory connectionFacto
IDbConnectionPool newPool;
if (LocalAppContextSwitches.UseConnectionPoolV2)
{
// ChannelDbConnectionPool is the v2 pool implementation
newPool = new ChannelDbConnectionPool();
throw new NotImplementedException();
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,38 @@ namespace Microsoft.Data.SqlClient.ConnectionPool
{
/// <summary>
/// A base interface for implementing database connection pools.
/// Derived classes are responsible for managing the lifecycle
/// Implementations are responsible for managing the lifecycle
/// of connections and providing access to database connections.
/// </summary>
internal interface IDbConnectionPool
{
#region Properties
/// <summary>
/// An id that uniqely identifies this connection pool.
/// Gets the authentication contexts cached by the pool.
/// </summary>
int ObjectId { get; }
ConcurrentDictionary<DbConnectionPoolAuthenticationContextKey, DbConnectionPoolAuthenticationContext> AuthenticationContexts { get; }

/// <summary>
/// The current state of the connection pool.
/// Gets the factory used to create database connections.
/// </summary>
DbConnectionPoolState State { get; set; }
DbConnectionFactory ConnectionFactory { get; }

/// <summary>
/// The number of connections currently managed by the pool.
/// May be larger than the number of connections currently sitting idle in the pool.
/// </summary>
int Count { get; }

/// <summary>
/// Gets the factory used to create database connections.
/// </summary>
DbConnectionFactory ConnectionFactory { get; }

/// <summary>
/// Indicates whether an error has occurred in the pool.
/// Primarily used to support the pool blocking period feature.
/// </summary>
bool ErrorOccurred { get; }

/// <summary>
/// Gets the duration of time to wait before reassigning a connection to a different server in a load-balanced
/// environment.
/// An id that uniqely identifies this connection pool.
/// </summary>
TimeSpan LoadBalanceTimeout { get; }
int Id { get; }

/// <summary>
/// Gets the identity used by the connection pool when establishing connections.
Expand All @@ -63,6 +57,12 @@ internal interface IDbConnectionPool
/// </summary>
bool IsRunning { get; }

/// <summary>
/// Gets the duration of time to wait before reassigning a connection to a different server in a load-balanced
/// environment.
/// </summary>
TimeSpan LoadBalanceTimeout { get; }

/// <summary>
/// Gets a reference to the connection pool group that this pool belongs to.
/// </summary>
Expand All @@ -79,9 +79,9 @@ internal interface IDbConnectionPool
DbConnectionPoolProviderInfo ProviderInfo { get; }

/// <summary>
/// Gets the authentication contexts cached by the pool.
/// The current state of the connection pool.
/// </summary>
ConcurrentDictionary<DbConnectionPoolAuthenticationContextKey, DbConnectionPoolAuthenticationContext> AuthenticationContexts { get; }
DbConnectionPoolState State { get; set; }

/// <summary>
/// Indicates whether the connection pool is using load balancing.
Expand All @@ -103,7 +103,7 @@ internal interface IDbConnectionPool
/// The internal connection will be set on completion source rather than passed out via the out parameter.</param>
/// <param name="userOptions">The user options to use if a new connection must be opened.</param>
/// <param name="connection">The retrieved connection will be passed out via this parameter.</param>
/// <returns>Returns true if a connection was set in the out parameter, otherwise returns false.</returns>
/// <returns>True if a connection was set in the out parameter, otherwise returns false.</returns>
bool TryGetConnection(DbConnection owningObject, TaskCompletionSource<DbConnectionInternal> taskCompletionSource, DbConnectionOptions userOptions, out DbConnectionInternal connection);

/// <summary>
Expand All @@ -112,7 +112,7 @@ internal interface IDbConnectionPool
/// <param name="owningObject">The connection whos internal connection should be replaced.</param>
/// <param name="userOptions">The user options to use if a new connection must be opened.</param>
/// <param name="oldConnection">The internal connection currently associated with the owning object.</param>
/// <returns></returns>
/// <returns>A reference to the new DbConnectionInternal.</returns>
DbConnectionInternal ReplaceConnection(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection);

/// <summary>
Expand Down
Loading
Loading