Skip to content

Commit

Permalink
SNOW-902611 ClearAllPools removes entire SessionPools collection in n…
Browse files Browse the repository at this point in the history
…ew pool
  • Loading branch information
sfc-gh-mhofman committed Oct 31, 2023
1 parent 4c73d76 commit beca66b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Snowflake.Data.Tests/IntegrationTests/SFConnectionPoolIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public SFConnectionPoolIT(ConnectionPoolType connectionPoolTypeUnderTest)
SnowflakeDbConnectionPool.GetPool(ConnectionString); // to instantiate the pool used in tests
SnowflakeDbConnectionPool.GetPool(ConnectionString + " retryCount=1");
SnowflakeDbConnectionPool.GetPool(ConnectionString + " retryCount=2");
SnowflakeDbConnectionPool.SetPooling(true); // TODO: when no session pool created it doesn't do anything!!!! maybe this state should be at pool management layer, not session pool layer
SnowflakeDbConnectionPool.SetPooling(true);
SnowflakeDbConnectionPool.ClearAllPools();
s_logger.Debug($"---------------- BeforeTest ---------------------");
s_logger.Debug($"Testing Pool Type: {SnowflakeDbConnectionPool.GetConnectionPoolVersion()}");
Expand Down Expand Up @@ -183,9 +183,9 @@ public void TestConnectionPool()
[Test]
public void TestConnectionPoolIsFull()
{
var pool = SnowflakeDbConnectionPool.GetPool(ConnectionString);
SnowflakeDbConnectionPool.SetPooling(true);
SnowflakeDbConnectionPool.ClearAllPools();
SnowflakeDbConnectionPool.SetPooling(true);
var pool = SnowflakeDbConnectionPool.GetPool(ConnectionString);
SnowflakeDbConnectionPool.SetMaxPoolSize(2);
var conn1 = new SnowflakeDbConnection();
conn1.ConnectionString = ConnectionString;
Expand All @@ -202,6 +202,8 @@ public void TestConnectionPoolIsFull()
conn3.Open();
Assert.AreEqual(ConnectionState.Open, conn3.State);
SnowflakeDbConnectionPool.ClearAllPools();
pool = SnowflakeDbConnectionPool.GetPool(ConnectionString);
SnowflakeDbConnectionPool.SetMaxPoolSize(2);

conn1.Close();
Assert.AreEqual(1, pool.GetCurrentPoolSize());
Expand Down Expand Up @@ -370,10 +372,10 @@ public void TestNewConnectionPoolFull()
{
TestOnlyForNewPool();

var sessionPool = SnowflakeDbConnectionPool.GetPool(ConnectionString);
SnowflakeDbConnectionPool.ClearAllPools();
SnowflakeDbConnectionPool.SetMaxPoolSize(2);
SnowflakeDbConnectionPool.SetPooling(true);
var sessionPool = SnowflakeDbConnectionPool.GetPool(ConnectionString);
SnowflakeDbConnectionPool.SetMaxPoolSize(2);

var conn1 = new SnowflakeDbConnection();
conn1.ConnectionString = ConnectionString;
Expand Down Expand Up @@ -456,6 +458,7 @@ void ThreadProcess2(string connstr)
public void TestConnectionPoolDisable()
{
SnowflakeDbConnectionPool.ClearAllPools();
SnowflakeDbConnectionPool.GetPool(ConnectionString);
SnowflakeDbConnectionPool.SetPooling(false);

var conn1 = new SnowflakeDbConnection();
Expand Down
1 change: 1 addition & 0 deletions Snowflake.Data/Core/Session/ConnectionPoolManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void ClearAllPools()
{
sessionPool.ClearAllPools();
}
_pools.Clear();
}

public void SetMaxPoolSize(int maxPoolSize)
Expand Down

0 comments on commit beca66b

Please sign in to comment.