Skip to content

Commit

Permalink
fix cancellation case
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-knozderko committed Jan 26, 2024
1 parent 9f585a2 commit 284b36a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Snowflake.Data/Core/Session/SessionPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ private Task<SFSession> NewSessionAsync(String connectionString, SecureString pa
return session
.OpenAsync(cancellationToken)
.ContinueWith(previousTask =>
{
_sessionCreationTokenCounter.RemoveToken(sessionCreationToken);
}, TaskContinuationOptions.OnlyOnCanceled)
.ContinueWith(previousTask =>
{
if (previousTask.IsFaulted)
{
Expand All @@ -319,7 +323,7 @@ private Task<SFSession> NewSessionAsync(String connectionString, SecureString pa
_sessionPoolEventHandler.OnNewSessionCreated(this);
_sessionPoolEventHandler.OnSessionProvided(this);
return session;
}, TaskContinuationOptions.None); // previously it was NotOnCanceled but we would like to execute it even in case of cancellation to properly update counters
}, TaskContinuationOptions.NotOnCanceled);
}

internal bool AddSession(SFSession session)
Expand Down

0 comments on commit 284b36a

Please sign in to comment.