Skip to content

Commit

Permalink
SNOW-878067: Set maxHttpRetries to 0 to reach the defined timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-lf committed Nov 3, 2023
1 parent 5e9931e commit 4cc94f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
12 changes: 6 additions & 6 deletions Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public void TestLoginTimeout()
using (IDbConnection conn = new MockSnowflakeDbConnection())
{
int timeoutSec = 5;
string loginTimeOut5sec = String.Format(ConnectionString + "connection_timeout={0}",
string loginTimeOut5sec = String.Format(ConnectionString + "connection_timeout={0};maxHttpRetries=0",
timeoutSec);

conn.ConnectionString = loginTimeOut5sec;
Expand All @@ -404,8 +404,8 @@ public void TestLoginTimeout()

// Should timeout before the defined timeout plus 1 (buffer time)
Assert.LessOrEqual(stopwatch.ElapsedMilliseconds, (timeoutSec + 1) * 1000);
// Should timeout after the minimum possible timeout with jitter
Assert.GreaterOrEqual(stopwatch.ElapsedMilliseconds, 1 * 1000 - delta);
// Should timeout after the defined timeout since retry count is infinite
Assert.GreaterOrEqual(stopwatch.ElapsedMilliseconds, timeoutSec * 1000 - delta);

Assert.AreEqual(timeoutSec, conn.ConnectionTimeout);
}
Expand Down Expand Up @@ -1724,7 +1724,7 @@ public void TestAsyncLoginTimeout()
using (var conn = new MockSnowflakeDbConnection())
{
int timeoutSec = 5;
string loginTimeOut5sec = String.Format(ConnectionString + "connection_timeout={0}",
string loginTimeOut5sec = String.Format(ConnectionString + "connection_timeout={0};maxHttpRetries=0",
timeoutSec);
conn.ConnectionString = loginTimeOut5sec;

Expand All @@ -1745,8 +1745,8 @@ public void TestAsyncLoginTimeout()
stopwatch.Stop();
int delta = 10; // in case server time slower.

// Should timeout after the minimum possible timeout with jitter
Assert.GreaterOrEqual(stopwatch.ElapsedMilliseconds, 1 * 1000 - delta);
// Should timeout after the defined timeout since retry count is infinite
Assert.GreaterOrEqual(stopwatch.ElapsedMilliseconds, timeoutSec * 1000 - delta);
// But never more than 1 sec (buffer time) after the defined timeout
Assert.LessOrEqual(stopwatch.ElapsedMilliseconds, (timeoutSec + 1) * 1000);

Expand Down
1 change: 0 additions & 1 deletion Snowflake.Data/Core/HttpUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,6 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage

requestMessage.RequestUri = updater.Update(errorReason);


logger.Debug($"Sleep {backOffInSec} seconds and then retry the request, retryCount: {retryCount}");

await Task.Delay(TimeSpan.FromSeconds(backOffInSec), cancellationToken).ConfigureAwait(false);
Expand Down

0 comments on commit 4cc94f7

Please sign in to comment.