Skip to content

Commit

Permalink
some testing
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-knozderko committed Apr 19, 2024
1 parent 12b6bf0 commit d821a37
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
10 changes: 9 additions & 1 deletion Snowflake.Data/Core/Authenticator/OktaAuthenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ private void HandleAuthenticatorException(Exception ex, HttpResponseMessage saml

// Get the current retry count and timeout elapsed from the response headers
retryCount += int.Parse(samlRawResponse.Content.Headers.GetValues(RetryCountHeader).First());
var timeoutElapsedHeader = int.Parse(samlRawResponse.Content.Headers.GetValues(TimeoutElapsedHeader).First());
s_logger.Warn($"HandleAuthenticatorException - timeoutElapsedHeader = {timeoutElapsedHeader} !!!");
timeoutElapsed += int.Parse(samlRawResponse.Content.Headers.GetValues(TimeoutElapsedHeader).First());
}
else
Expand Down Expand Up @@ -275,7 +277,13 @@ private void VerifyPostbackUrl()
private bool RetryLimitIsNotReached(int retryCount, int timeoutElapsed)
{
var elapsedMillis = timeoutElapsed * 1000;
return retryCount < session._maxRetryCount && !TimeoutHelper.IsExpired(elapsedMillis, session._maxRetryTimeout);
var result = retryCount < session._maxRetryCount && !TimeoutHelper.IsExpired(elapsedMillis, session._maxRetryTimeout);
if (!result)
{
s_logger.Warn($"Reached retry timeout: {timeoutElapsed} - !!!");
}

return result;
}

private bool IsPostbackUrlNotFound(Exception ex)
Expand Down
18 changes: 9 additions & 9 deletions Snowflake.Data/Core/SFStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ class SFStatement
private readonly IRestRequester _restRequester;

private CancellationTokenSource _timeoutTokenSource;
// Merged cancellation token source for all cancellation signal.

// Merged cancellation token source for all cancellation signal.
// Cancel callback will be registered under token issued by this source.
private CancellationTokenSource _linkedCancellationTokenSource;

Expand Down Expand Up @@ -153,7 +153,7 @@ private void AssignQueryRequestId()
{
lock (_requestIdLock)
{

if (_requestId != null)
{
logger.Info("Another query is running.");
Expand Down Expand Up @@ -296,7 +296,7 @@ private void SetTimeout(int timeout)
this._timeoutTokenSource = timeout > 0 ? new CancellationTokenSource(timeout * 1000) :
new CancellationTokenSource(Timeout.InfiniteTimeSpan);
}

/// <summary>
/// Register cancel callback. Two factors: either external cancellation token passed down from upper
/// layer or timeout reached. Whichever comes first would trigger query cancellation.
Expand Down Expand Up @@ -342,7 +342,7 @@ internal async Task<SFBaseResultSet> ExecuteAsync(int timeout, string sql, Dicti
}

registerQueryCancellationCallback(timeout, cancellationToken);

int arrayBindingThreshold = 0;
if (SfSession.ParameterMap.ContainsKey(SFSessionParameter.CLIENT_STAGE_ARRAY_BINDING_THRESHOLD))
{
Expand Down Expand Up @@ -486,7 +486,7 @@ private SFBaseResultSet ExecuteSqlWithPutGet(int timeout, string sql, Dictionary
throw new SnowflakeDbException(ex, SFError.INTERNAL_ERROR);
}
}

private SFBaseResultSet ExecuteSqlOtherThanPutGet(int timeout, string sql, Dictionary<string, BindingDTO> bindings, bool describeOnly, bool asyncExec)
{
try
Expand Down Expand Up @@ -541,7 +541,7 @@ private SFBaseResultSet ExecuteSqlOtherThanPutGet(int timeout, string sql, Dicti
throw;
}
}

internal async Task<SFBaseResultSet> GetResultWithIdAsync(string resultId, CancellationToken cancellationToken)
{
var req = BuildResultRequestWithId(resultId);
Expand Down Expand Up @@ -660,7 +660,7 @@ internal T ExecuteHelper<T, U>(

if (SessionExpired(response))
{
logger.Info("Ping pong request failed with session expired, trying to renew the session.");
logger.Warn("Ping pong request failed with session expired, trying to renew the session. !!!"); // it was info previously
SfSession.renewSession();
}
else
Expand Down Expand Up @@ -1033,7 +1033,7 @@ internal SFBaseResultSet ExecuteTransfer(string sql)
false);

PutGetStageInfo stageInfo = new PutGetStageInfo();

SFFileTransferAgent fileTransferAgent =
new SFFileTransferAgent(sql, SfSession, response.data, ref _uploadStream, _destFilename, _stagePath, CancellationToken.None);

Expand Down

0 comments on commit d821a37

Please sign in to comment.