Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-hx committed Nov 18, 2023
1 parent d7ff72f commit afae0fb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Snowflake.Data.Tests/IntegrationTests/SFDbCommandIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void TestExecAsyncAPIParallel()
connectTask.Wait();
Assert.AreEqual(ConnectionState.Open, conn.State);

Task[] taskArray = new Task[1];
Task[] taskArray = new Task[5];
for (int i = 0; i < taskArray.Length; i++)
{
taskArray[i] = Task.Factory.StartNew(() =>
Expand Down Expand Up @@ -108,7 +108,7 @@ public void TestExecAsyncAPIParallel()
[Test]
public void TestCancelExecuteAsync()
{
CancellationTokenSource externalCancel = new CancellationTokenSource(TimeSpan.FromSeconds(2));
CancellationTokenSource externalCancel = new CancellationTokenSource(TimeSpan.FromSeconds(8));

using (DbConnection conn = new SnowflakeDbConnection())
{
Expand Down Expand Up @@ -454,7 +454,7 @@ public void TestCancelQuery()
}
});

Thread.Sleep(2000);
Thread.Sleep(8000);
cmd.Cancel();

try
Expand Down
19 changes: 19 additions & 0 deletions Snowflake.Data.Tests/UnitTests/QueryContextCacheTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,25 @@ public void TestMoreThanCapacity()
AssertCacheData();
}

[Test]
public void TestChangingCapacity()
{
InitCacheWithData();

// Add one more element at the end
int i = MaxCapacity;
_qcc.SetCapacity(MaxCapacity + 1);
_qcc.Merge(BaseId + i, BaseReadTimestamp + i, BasePriority + i, Context);
_qcc.SyncPriorityMap();
_qcc.CheckCacheCapacity();
Assert.IsTrue(_qcc.GetSize() == MaxCapacity + 1);

// reduce the capacity back
_qcc.SetCapacity(MaxCapacity);
// Compare elements
AssertCacheData();
}

[Test]
public void TestUpdateTimestamp()
{
Expand Down
5 changes: 2 additions & 3 deletions Snowflake.Data/Core/SFStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ private SFRestRequest BuildCancelQueryRequest()

internal void Cancel()
{
logger.Info("canceling request" + _requestId);
SFRestRequest request = BuildCancelQueryRequest();
if (request == null)
{
Expand All @@ -474,11 +473,11 @@ internal void Cancel()

if (response.success)
{
logger.Info("Query cancellation succeed: " + ((QueryCancelRequest)(request.jsonBody)).requestId);
logger.Info("Query cancellation succeed");
}
else
{
logger.Warn("Query cancellation failed: " + ((QueryCancelRequest)(request.jsonBody)).requestId + ", " + response.message);
logger.Warn("Query cancellation failed.");
}
CleanUpCancellationTokenSources();
}
Expand Down

0 comments on commit afae0fb

Please sign in to comment.