From 259e67a2fa7a76ceae42d074d50ebc2e98a20080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Hofman?= Date: Mon, 30 Oct 2023 19:43:09 +0100 Subject: [PATCH] Increased code coverage for connection pool and review suggestions --- .../IntegrationTests/SFConnectionPoolIT.cs | 66 +++++-------------- .../ConnectionPoolManagerSwitchTest.cs | 23 +++++++ .../UnitTests/ConnectionPoolManagerTest.cs | 54 +++++++++++++-- .../Client/SnowflakeDbConnectionPool.cs | 10 +-- Snowflake.Data/Core/ErrorMessages.resx | 3 + Snowflake.Data/Core/SFError.cs | 3 + .../Core/Session/ConnectionPoolManager.cs | 25 ++++--- Snowflake.Data/Core/Session/SFSession.cs | 4 +- 8 files changed, 116 insertions(+), 72 deletions(-) create mode 100644 Snowflake.Data.Tests/UnitTests/ConnectionPoolManagerSwitchTest.cs diff --git a/Snowflake.Data.Tests/IntegrationTests/SFConnectionPoolIT.cs b/Snowflake.Data.Tests/IntegrationTests/SFConnectionPoolIT.cs index a1b9d3cb8..ae4162c65 100644 --- a/Snowflake.Data.Tests/IntegrationTests/SFConnectionPoolIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/SFConnectionPoolIT.cs @@ -29,17 +29,14 @@ public SFConnectionPoolIT(ConnectionPoolType connectionPoolTypeUnderTest) { _connectionPoolTypeUnderTest = connectionPoolTypeUnderTest; s_previousPoolConfig = new PoolConfig(); - SnowflakeDbConnectionPool.SetConnectionPoolVersion(connectionPoolTypeUnderTest); } [SetUp] public new void BeforeTest() { - SnowflakeDbConnectionPool.GetPool(ConnectionString); // to instantiate the pool used in tests - SnowflakeDbConnectionPool.GetPool(ConnectionString + " retryCount=1"); - SnowflakeDbConnectionPool.GetPool(ConnectionString + " retryCount=2"); - SnowflakeDbConnectionPool.SetPooling(true); + SnowflakeDbConnectionPool.SetConnectionPoolVersion(_connectionPoolTypeUnderTest); SnowflakeDbConnectionPool.ClearAllPools(); + SnowflakeDbConnectionPool.SetPooling(true); s_logger.Debug($"---------------- BeforeTest ---------------------"); s_logger.Debug($"Testing Pool Type: {SnowflakeDbConnectionPool.GetConnectionPoolVersion()}"); } @@ -85,10 +82,8 @@ static void ConcurrentPoolingHelper(string connectionString, bool closeConnectio const int PoolTimeout = 3; // reset to default settings in case it changed by other test cases - SnowflakeDbConnectionPool.GetPool(connectionString); // to instantiate pool - SnowflakeDbConnectionPool.SetPooling(true); + Assert.AreEqual(true, SnowflakeDbConnectionPool.GetPool(connectionString).GetPooling()); // to instantiate pool SnowflakeDbConnectionPool.SetMaxPoolSize(10); - SnowflakeDbConnectionPool.ClearAllPools(); SnowflakeDbConnectionPool.SetTimeout(PoolTimeout); var threads = new Task[ThreadNum]; @@ -100,8 +95,6 @@ static void ConcurrentPoolingHelper(string connectionString, bool closeConnectio }); } Task.WaitAll(threads); - // set pooling timeout back to default to avoid impact on other test cases - SnowflakeDbConnectionPool.SetTimeout(3600); } // thead to execute query with new connection in a loop @@ -160,7 +153,6 @@ public void TestBasicConnectionPool() [Test] public void TestConnectionPool() { - SnowflakeDbConnectionPool.ClearAllPools(); var conn1 = new SnowflakeDbConnection(ConnectionString); conn1.Open(); Assert.AreEqual(ConnectionState.Open, conn1.State); @@ -177,14 +169,11 @@ public void TestConnectionPool() Assert.AreEqual(1, SnowflakeDbConnectionPool.GetPool(ConnectionString).GetCurrentPoolSize()); Assert.AreEqual(ConnectionState.Closed, conn1.State); Assert.AreEqual(ConnectionState.Closed, conn2.State); - SnowflakeDbConnectionPool.ClearAllPools(); } [Test] public void TestConnectionPoolIsFull() { - SnowflakeDbConnectionPool.ClearAllPools(); - SnowflakeDbConnectionPool.SetPooling(true); var pool = SnowflakeDbConnectionPool.GetPool(ConnectionString); SnowflakeDbConnectionPool.SetMaxPoolSize(2); var conn1 = new SnowflakeDbConnection(); @@ -221,10 +210,8 @@ public void TestConnectionPoolIsFull() [Test] public void TestConnectionPoolExpirationWorks() { - SnowflakeDbConnectionPool.ClearAllPools(); SnowflakeDbConnectionPool.SetMaxPoolSize(2); SnowflakeDbConnectionPool.SetTimeout(10); - SnowflakeDbConnectionPool.SetPooling(true); var conn1 = new SnowflakeDbConnection(); conn1.ConnectionString = ConnectionString; @@ -254,7 +241,6 @@ public void TestConnectionPoolClean() { TestOnlyForOldPool(); - SnowflakeDbConnectionPool.ClearAllPools(); SnowflakeDbConnectionPool.SetMaxPoolSize(2); var conn1 = new SnowflakeDbConnection(); conn1.ConnectionString = ConnectionString; @@ -282,7 +268,6 @@ public void TestConnectionPoolClean() Assert.AreEqual(ConnectionState.Closed, conn1.State); Assert.AreEqual(ConnectionState.Closed, conn2.State); Assert.AreEqual(ConnectionState.Closed, conn3.State); - SnowflakeDbConnectionPool.ClearAllPools(); } [Test] @@ -290,7 +275,6 @@ public void TestNewConnectionPoolClean() { TestOnlyForNewPool(); - SnowflakeDbConnectionPool.ClearAllPools(); SnowflakeDbConnectionPool.SetMaxPoolSize(2); var conn1 = new SnowflakeDbConnection(); conn1.ConnectionString = ConnectionString; @@ -320,7 +304,6 @@ public void TestNewConnectionPoolClean() Assert.AreEqual(ConnectionState.Closed, conn1.State); Assert.AreEqual(ConnectionState.Closed, conn2.State); Assert.AreEqual(ConnectionState.Closed, conn3.State); - SnowflakeDbConnectionPool.ClearAllPools(); } [Test] @@ -328,9 +311,7 @@ public void TestConnectionPoolFull() { TestOnlyForOldPool(); - SnowflakeDbConnectionPool.ClearAllPools(); SnowflakeDbConnectionPool.SetMaxPoolSize(2); - SnowflakeDbConnectionPool.SetPooling(true); var conn1 = new SnowflakeDbConnection(); conn1.ConnectionString = ConnectionString; @@ -372,10 +353,8 @@ public void TestNewConnectionPoolFull() { TestOnlyForNewPool(); - SnowflakeDbConnectionPool.ClearAllPools(); - SnowflakeDbConnectionPool.SetPooling(true); - var sessionPool = SnowflakeDbConnectionPool.GetPool(ConnectionString); - SnowflakeDbConnectionPool.SetMaxPoolSize(2); + var pool = SnowflakeDbConnectionPool.GetPool(ConnectionString); + pool.SetMaxPoolSize(2); var conn1 = new SnowflakeDbConnection(); conn1.ConnectionString = ConnectionString; @@ -387,10 +366,10 @@ public void TestNewConnectionPoolFull() conn2.Open(); Assert.AreEqual(ConnectionState.Open, conn2.State); - Assert.AreEqual(0, sessionPool.GetCurrentPoolSize()); + Assert.AreEqual(0, pool.GetCurrentPoolSize()); conn1.Close(); conn2.Close(); - Assert.AreEqual(2, sessionPool.GetCurrentPoolSize()); + Assert.AreEqual(2, pool.GetCurrentPoolSize()); var conn3 = new SnowflakeDbConnection(); conn3.ConnectionString = ConnectionString; @@ -403,15 +382,14 @@ public void TestNewConnectionPoolFull() Assert.AreEqual(ConnectionState.Open, conn4.State); conn3.Close(); - Assert.AreEqual(1, sessionPool.GetCurrentPoolSize()); // TODO: when SNOW-937189 complete should be 2 + Assert.AreEqual(1, pool.GetCurrentPoolSize()); // TODO: when SNOW-937189 complete should be 2 conn4.Close(); - Assert.AreEqual(2, sessionPool.GetCurrentPoolSize()); + Assert.AreEqual(2, pool.GetCurrentPoolSize()); Assert.AreEqual(ConnectionState.Closed, conn1.State); Assert.AreEqual(ConnectionState.Closed, conn2.State); Assert.AreEqual(ConnectionState.Closed, conn3.State); Assert.AreEqual(ConnectionState.Closed, conn4.State); - SnowflakeDbConnectionPool.ClearAllPools(); } [Test] @@ -457,9 +435,8 @@ void ThreadProcess2(string connstr) [Test] public void TestConnectionPoolDisable() { - SnowflakeDbConnectionPool.ClearAllPools(); - SnowflakeDbConnectionPool.GetPool(ConnectionString); - SnowflakeDbConnectionPool.SetPooling(false); + var pool = SnowflakeDbConnectionPool.GetPool(ConnectionString); + pool.SetPooling(false); var conn1 = new SnowflakeDbConnection(); conn1.ConnectionString = ConnectionString; @@ -468,27 +445,18 @@ public void TestConnectionPoolDisable() conn1.Close(); Assert.AreEqual(ConnectionState.Closed, conn1.State); - Assert.AreEqual(0, SnowflakeDbConnectionPool.GetPool(ConnectionString).GetCurrentPoolSize()); + Assert.AreEqual(0, pool.GetCurrentPoolSize()); } [Test] public void TestConnectionPoolWithDispose() { - SnowflakeDbConnectionPool.SetPooling(true); SnowflakeDbConnectionPool.SetMaxPoolSize(1); - SnowflakeDbConnectionPool.ClearAllPools(); - + var conn1 = new SnowflakeDbConnection(); conn1.ConnectionString = "bad connection string"; - try - { - conn1.Open(); - } - catch (SnowflakeDbException ex) - { - Console.WriteLine("connection failed:" + ex); - conn1.Close(); - } + Assert.Throws(() => conn1.Open()); + conn1.Close(); Assert.AreEqual(ConnectionState.Closed, conn1.State); Assert.AreEqual(0, SnowflakeDbConnectionPool.GetPool(conn1.ConnectionString).GetCurrentPoolSize()); @@ -500,7 +468,6 @@ public void TestConnectionPoolTurnOff() SnowflakeDbConnectionPool.SetPooling(false); SnowflakeDbConnectionPool.SetPooling(true); SnowflakeDbConnectionPool.SetMaxPoolSize(1); - SnowflakeDbConnectionPool.ClearAllPools(); var conn1 = new SnowflakeDbConnection(); conn1.ConnectionString = ConnectionString; @@ -510,9 +477,6 @@ public void TestConnectionPoolTurnOff() Assert.AreEqual(ConnectionState.Closed, conn1.State); Assert.AreEqual(1, SnowflakeDbConnectionPool.GetPool(ConnectionString).GetCurrentPoolSize()); - - SnowflakeDbConnectionPool.SetPooling(false); - //Put a breakpoint at SFSession close function, after connection pool is off, it will send close session request. } private void TestOnlyForOldPool() diff --git a/Snowflake.Data.Tests/UnitTests/ConnectionPoolManagerSwitchTest.cs b/Snowflake.Data.Tests/UnitTests/ConnectionPoolManagerSwitchTest.cs new file mode 100644 index 000000000..bf40a7710 --- /dev/null +++ b/Snowflake.Data.Tests/UnitTests/ConnectionPoolManagerSwitchTest.cs @@ -0,0 +1,23 @@ +using NUnit.Framework; +using Snowflake.Data.Client; +using Snowflake.Data.Core.Session; + +namespace Snowflake.Data.Tests.UnitTests +{ + public class ConnectionPoolManagerSwitchTest + { + private readonly string _connectionString1 = "database=D1;warehouse=W1;account=A1;user=U1;password=P1;role=R1;"; + private readonly string _connectionString2 = "database=D2;warehouse=W2;account=A2;user=U2;password=P2;role=R2;"; + + [Test] + public void TestRevertPoolToPreviousVersion() + { + SnowflakeDbConnectionPool.SetOldConnectionPoolVersion(); + + var sessionPool1 = SnowflakeDbConnectionPool.GetPool(_connectionString1); + var sessionPool2 = SnowflakeDbConnectionPool.GetPool(_connectionString2); + Assert.AreEqual(ConnectionPoolType.SingleConnectionCache, SnowflakeDbConnectionPool.GetConnectionPoolVersion()); + Assert.AreEqual(sessionPool1, sessionPool2); + } + } +} \ No newline at end of file diff --git a/Snowflake.Data.Tests/UnitTests/ConnectionPoolManagerTest.cs b/Snowflake.Data.Tests/UnitTests/ConnectionPoolManagerTest.cs index ed3c12bb8..82458023e 100644 --- a/Snowflake.Data.Tests/UnitTests/ConnectionPoolManagerTest.cs +++ b/Snowflake.Data.Tests/UnitTests/ConnectionPoolManagerTest.cs @@ -2,7 +2,7 @@ * Copyright (c) 2023 Snowflake Computing Inc. All rights reserved. */ -using System; +using System.Collections.Generic; using System.Security; using System.Threading; using System.Threading.Tasks; @@ -116,7 +116,6 @@ public void TestCountingOfSessionProvidedByPool() } [Test] - [Ignore("Enable after completion of SNOW-937189")] // TODO: public void TestCountingOfSessionReturnedBackToPool() { // Arrange @@ -197,7 +196,10 @@ public void TestGetPoolingOnManagerLevelWhenNotAllPoolsEqual() sessionPool2.SetPooling(false); // Act/Assert - Assert.Throws(() => _connectionPoolManager.GetPooling()); + var exception = Assert.Throws(() => _connectionPoolManager.GetPooling()); + Assert.IsNotNull(exception); + Assert.AreEqual(SFError.INCONSISTENT_RESULT_ERROR.GetAttribute().errorCode, exception.ErrorCode); + Assert.IsTrue(exception.Message.Contains("Multiple pools have different Pooling values")); } [Test] @@ -223,7 +225,10 @@ public void TestGetTimeoutOnManagerLevelWhenNotAllPoolsEqual() sessionPool2.SetTimeout(1313); // Act/Assert - Assert.Throws(() => _connectionPoolManager.GetTimeout()); + var exception = Assert.Throws(() => _connectionPoolManager.GetTimeout()); + Assert.IsNotNull(exception); + Assert.AreEqual(SFError.INCONSISTENT_RESULT_ERROR.GetAttribute().errorCode, exception.ErrorCode); + Assert.IsTrue(exception.Message.Contains("Multiple pools have different Timeout values")); } [Test] @@ -249,7 +254,10 @@ public void TestGetMaxPoolSizeOnManagerLevelWhenNotAllPoolsEqual() sessionPool2.SetMaxPoolSize(17); // Act/Assert - Assert.Throws(() => _connectionPoolManager.GetMaxPoolSize()); + var exception = Assert.Throws(() => _connectionPoolManager.GetMaxPoolSize()); + Assert.IsNotNull(exception); + Assert.AreEqual(SFError.INCONSISTENT_RESULT_ERROR.GetAttribute().errorCode, exception.ErrorCode); + Assert.IsTrue(exception.Message.Contains("Multiple pools have different Max Pool Size values")); } [Test] @@ -264,6 +272,40 @@ public void TestGetMaxPoolSizeOnManagerLevelWhenAllPoolsEqual() // Act/Assert Assert.AreEqual(33,_connectionPoolManager.GetMaxPoolSize()); } + + [Test] + public void TestGetCurrentPoolSizeThrowsExceptionWhenNotAllPoolsEqual() + { + // Arrange + EnsurePoolSize(_connectionString1, 2); + EnsurePoolSize(_connectionString2, 3); + + // Act/Assert + var exception = Assert.Throws(() => _connectionPoolManager.GetCurrentPoolSize()); + Assert.IsNotNull(exception); + Assert.AreEqual(SFError.INCONSISTENT_RESULT_ERROR.GetAttribute().errorCode, exception.ErrorCode); + Assert.IsTrue(exception.Message.Contains("Multiple pools have different Current Pool Size values")); + } + + private void EnsurePoolSize(string connectionString, int requiredCurrentSize) + { + var sessionPool = _connectionPoolManager.GetPool(connectionString, _password); + sessionPool.SetMaxPoolSize(requiredCurrentSize); + var busySessions = new List(); + for (var i = 0; i < requiredCurrentSize; i++) + { + var sfSession = _connectionPoolManager.GetSession(connectionString, _password); + busySessions.Add(sfSession); + } + + foreach (var session in busySessions) // TODO: remove after SNOW-937189 since sessions will be already counted by GetCurrentPool size + { + session.close(); + _connectionPoolManager.AddSession(session); + } + + Assert.AreEqual(requiredCurrentSize, sessionPool.GetCurrentPoolSize()); + } } class MockSessionFactory : ISessionFactory @@ -273,6 +315,8 @@ public SFSession NewSession(string connectionString, SecureString password) var mockSfSession = new Mock(connectionString, password); mockSfSession.Setup(x => x.Open()).Verifiable(); mockSfSession.Setup(x => x.OpenAsync(default)).Returns(Task.FromResult(this)); + mockSfSession.Setup(x => x.IsNotOpen()).Returns(false); + mockSfSession.Setup(x => x.IsExpired(It.IsAny(), It.IsAny())).Returns(false); return mockSfSession.Object; } } diff --git a/Snowflake.Data/Client/SnowflakeDbConnectionPool.cs b/Snowflake.Data/Client/SnowflakeDbConnectionPool.cs index f87e9e83b..46348cf61 100644 --- a/Snowflake.Data/Client/SnowflakeDbConnectionPool.cs +++ b/Snowflake.Data/Client/SnowflakeDbConnectionPool.cs @@ -17,7 +17,7 @@ public class SnowflakeDbConnectionPool private static readonly SFLogger s_logger = SFLoggerFactory.GetLogger(); private static readonly Object s_connectionManagerInstanceLock = new Object(); private static IConnectionManager s_connectionManager; - private const ConnectionPoolType DefaultConnectionPoolType = ConnectionPoolType.SingleConnectionCache; // TODO: set to public once development of entire ConnectionPoolManager epic is complete + private const ConnectionPoolType DefaultConnectionPoolType = ConnectionPoolType.SingleConnectionCache; // TODO: set to MultipleConnectionPool once development of entire ConnectionPoolManager epic is complete private static IConnectionManager ConnectionManager { @@ -32,13 +32,13 @@ private static IConnectionManager ConnectionManager internal static SFSession GetSession(string connectionString, SecureString password) { - s_logger.Debug($"SnowflakeDbConnectionPool::GetSession for {connectionString}"); + s_logger.Debug($"SnowflakeDbConnectionPool::GetSession"); return ConnectionManager.GetSession(connectionString, password); } internal static Task GetSessionAsync(string connectionString, SecureString password, CancellationToken cancellationToken) { - s_logger.Debug($"SnowflakeDbConnectionPool::GetSessionAsync for {connectionString}"); + s_logger.Debug($"SnowflakeDbConnectionPool::GetSessionAsync"); return ConnectionManager.GetSessionAsync(connectionString, password, cancellationToken); } @@ -112,12 +112,12 @@ internal static void SetConnectionPoolVersion(ConnectionPoolType requestedPoolTy lock (s_connectionManagerInstanceLock) { s_connectionManager?.ClearAllPools(); - if (ConnectionPoolType.MultipleConnectionPool.Equals(requestedPoolType)) + if (requestedPoolType == ConnectionPoolType.MultipleConnectionPool) { s_connectionManager = new ConnectionPoolManager(); s_logger.Info("SnowflakeDbConnectionPool - multiple connection pools enabled"); } - if (ConnectionPoolType.SingleConnectionCache.Equals(requestedPoolType)) + if (requestedPoolType == ConnectionPoolType.SingleConnectionCache) { s_connectionManager = new ConnectionCacheManager(); s_logger.Warn("SnowflakeDbConnectionPool - connection cache enabled"); diff --git a/Snowflake.Data/Core/ErrorMessages.resx b/Snowflake.Data/Core/ErrorMessages.resx index 7159b86a0..8c50a5b57 100755 --- a/Snowflake.Data/Core/ErrorMessages.resx +++ b/Snowflake.Data/Core/ErrorMessages.resx @@ -183,4 +183,7 @@ Browser response timed out after {0} seconds. + + Cannot return result set as a scalar value: {0} + \ No newline at end of file diff --git a/Snowflake.Data/Core/SFError.cs b/Snowflake.Data/Core/SFError.cs index 2aac72f16..3a71e95fb 100755 --- a/Snowflake.Data/Core/SFError.cs +++ b/Snowflake.Data/Core/SFError.cs @@ -78,6 +78,9 @@ public enum SFError [SFErrorAttr(errorCode = 270057)] BROWSER_RESPONSE_TIMEOUT, + + [SFErrorAttr(errorCode = 270058)] + INCONSISTENT_RESULT_ERROR, } class SFErrorAttr : Attribute diff --git a/Snowflake.Data/Core/Session/ConnectionPoolManager.cs b/Snowflake.Data/Core/Session/ConnectionPoolManager.cs index d42102992..9fa2309e1 100644 --- a/Snowflake.Data/Core/Session/ConnectionPoolManager.cs +++ b/Snowflake.Data/Core/Session/ConnectionPoolManager.cs @@ -29,13 +29,13 @@ internal ConnectionPoolManager() public SFSession GetSession(string connectionString, SecureString password) { - s_logger.Debug($"ConnectionPoolManager::GetSession for {connectionString}"); + s_logger.Debug($"ConnectionPoolManager::GetSession"); return GetPool(connectionString, password).GetSession(); } public Task GetSessionAsync(string connectionString, SecureString password, CancellationToken cancellationToken) { - s_logger.Debug($"ConnectionPoolManager::GetSessionAsync for {connectionString}"); + s_logger.Debug($"ConnectionPoolManager::GetSessionAsync"); return GetPool(connectionString, password).GetSessionAsync(cancellationToken); } @@ -70,7 +70,7 @@ public int GetMaxPoolSize() var values = _pools.Values.Select(it => it.GetMaxPoolSize()).Distinct().ToList(); return values.Count == 1 ? values.First() - : throw new SnowflakeDbException(SFError.INTERNAL_ERROR, "Multiple pools have different Max Pool Size values"); + : throw new SnowflakeDbException(SFError.INCONSISTENT_RESULT_ERROR, "Multiple pools have different Max Pool Size values"); } public void SetTimeout(long connectionTimeout) @@ -88,10 +88,17 @@ public long GetTimeout() var values = _pools.Values.Select(it => it.GetTimeout()).Distinct().ToList(); return values.Count == 1 ? values.First() - : throw new SnowflakeDbException(SFError.INTERNAL_ERROR, "Multiple pools have different Timeout values"); + : throw new SnowflakeDbException(SFError.INCONSISTENT_RESULT_ERROR, "Multiple pools have different Timeout values"); } - public int GetCurrentPoolSize() => throw new SnowflakeDbException(SFError.INTERNAL_ERROR, "Multiple pools have different Current Pool Size values"); + public int GetCurrentPoolSize() + { + s_logger.Debug("ConnectionPoolManager::GetCurrentPoolSize"); + var values = _pools.Values.Select(it => it.GetCurrentPoolSize()).Distinct().ToList(); + return values.Count == 1 + ? values.First() + : throw new SnowflakeDbException(SFError.INCONSISTENT_RESULT_ERROR, "Multiple pools have different Current Pool Size values"); + } public bool SetPooling(bool poolingEnabled) { @@ -111,12 +118,12 @@ public bool GetPooling() var values = _pools.Values.Select(it => it.GetPooling()).Distinct().ToList(); return values.Count == 1 ? values.First() - : throw new SnowflakeDbException(SFError.INTERNAL_ERROR, "Multiple pools have different Pooling values"); + : throw new SnowflakeDbException(SFError.INCONSISTENT_RESULT_ERROR, "Multiple pools have different Pooling values"); } internal SessionPool GetPool(string connectionString, SecureString password) { - s_logger.Debug($"ConnectionPoolManager::GetPool for {connectionString}"); + s_logger.Debug($"ConnectionPoolManager::GetPool"); var poolKey = GetPoolKey(connectionString); if (_pools.TryGetValue(poolKey, out var item)) @@ -125,7 +132,7 @@ internal SessionPool GetPool(string connectionString, SecureString password) { if (_pools.TryGetValue(poolKey, out var poolCreatedWhileWaitingOnLock)) return poolCreatedWhileWaitingOnLock; - s_logger.Info($"Creating pool for connections to: {connectionString}"); + s_logger.Info($"Creating new pool"); var pool = SessionPool.CreateSessionPool(connectionString, password); _pools.Add(poolKey, pool); return pool; @@ -134,7 +141,7 @@ internal SessionPool GetPool(string connectionString, SecureString password) public SessionPool GetPool(string connectionString) { - s_logger.Debug($"ConnectionPoolManager::GetPool for {connectionString}"); + s_logger.Debug($"ConnectionPoolManager::GetPool"); return GetPool(connectionString, null); } diff --git a/Snowflake.Data/Core/Session/SFSession.cs b/Snowflake.Data/Core/Session/SFSession.cs index f26de4f50..490e1dc06 100755 --- a/Snowflake.Data/Core/Session/SFSession.cs +++ b/Snowflake.Data/Core/Session/SFSession.cs @@ -556,12 +556,12 @@ internal void heartbeat() } } - internal bool IsNotOpen() + internal virtual bool IsNotOpen() { return _startTime == 0; } - internal bool IsExpired(long timeoutInSeconds, long utcTimeInSeconds) + internal virtual bool IsExpired(long timeoutInSeconds, long utcTimeInSeconds) { return _startTime + timeoutInSeconds <= utcTimeInSeconds; }