diff --git a/Snowflake.Data/Client/SnowflakeDbConnection.cs b/Snowflake.Data/Client/SnowflakeDbConnection.cs index 5a7e7fbee..a578d143d 100755 --- a/Snowflake.Data/Client/SnowflakeDbConnection.cs +++ b/Snowflake.Data/Client/SnowflakeDbConnection.cs @@ -153,8 +153,8 @@ public override void Close() { var transactionRollbackStatus = SnowflakeDbConnectionPool.GetPooling() ? TerminateTransactionForDirtyConnectionReturningToPool() : TransactionRollbackStatus.Undefined; - if (CanReuseSession(transactionRollbackStatus) && - SfSession.StillRunningAsyncQueries() && + if ((CanReuseSession(transactionRollbackStatus) || + SfSession.StillRunningAsyncQueries()) && SnowflakeDbConnectionPool.AddSession(SfSession) ) { @@ -194,8 +194,8 @@ public virtual async Task CloseAsync(CancellationToken cancellationToken) { var transactionRollbackStatus = SnowflakeDbConnectionPool.GetPooling() ? TerminateTransactionForDirtyConnectionReturningToPool() : TransactionRollbackStatus.Undefined; - if (CanReuseSession(transactionRollbackStatus) && - await SfSession.StillRunningAsyncQueriesAsync(cancellationToken).ConfigureAwait(false) && + if ((CanReuseSession(transactionRollbackStatus) || + await SfSession.StillRunningAsyncQueriesAsync(cancellationToken).ConfigureAwait(false)) && SnowflakeDbConnectionPool.AddSession(SfSession)) { logger.Debug($"Session pooled: {SfSession.sessionId}");