From beca66bd8da737b8c6cf8cf5eebc7244ead8fdad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Hofman?= Date: Tue, 17 Oct 2023 16:29:25 +0200 Subject: [PATCH] SNOW-902611 ClearAllPools removes entire SessionPools collection in new pool --- .../IntegrationTests/SFConnectionPoolIT.cs | 13 ++++++++----- .../Core/Session/ConnectionPoolManager.cs | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Snowflake.Data.Tests/IntegrationTests/SFConnectionPoolIT.cs b/Snowflake.Data.Tests/IntegrationTests/SFConnectionPoolIT.cs index 20784a27f..a1b9d3cb8 100644 --- a/Snowflake.Data.Tests/IntegrationTests/SFConnectionPoolIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/SFConnectionPoolIT.cs @@ -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()}"); @@ -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; @@ -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()); @@ -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; @@ -456,6 +458,7 @@ void ThreadProcess2(string connstr) public void TestConnectionPoolDisable() { SnowflakeDbConnectionPool.ClearAllPools(); + SnowflakeDbConnectionPool.GetPool(ConnectionString); SnowflakeDbConnectionPool.SetPooling(false); var conn1 = new SnowflakeDbConnection(); diff --git a/Snowflake.Data/Core/Session/ConnectionPoolManager.cs b/Snowflake.Data/Core/Session/ConnectionPoolManager.cs index 6f4bd5063..d42102992 100644 --- a/Snowflake.Data/Core/Session/ConnectionPoolManager.cs +++ b/Snowflake.Data/Core/Session/ConnectionPoolManager.cs @@ -52,6 +52,7 @@ public void ClearAllPools() { sessionPool.ClearAllPools(); } + _pools.Clear(); } public void SetMaxPoolSize(int maxPoolSize)