Skip to content

Commit

Permalink
Remove "DO SLEEP" calls in .NET connector
Browse files Browse the repository at this point in the history
Summary: Replace "DO SLEEP" calls in .NET connector with SingleStore equivalent "SELECT SLEEP() INTO @dummy".

Test Plan: .circleci: https://app.circleci.com/pipelines/github/memsql/SingleStoreNETConnector/38/workflows/dd7e09af-afb6-495d-befd-c2720cba1311/jobs/42

Reviewers: okramarenko-ua, pmishchenko-ua

Reviewed By: okramarenko-ua, pmishchenko-ua

Subscribers: engineering-list

JIRA Issues: PLAT-5985

Differential Revision: https://grizzly.internal.memcompute.com/D54188
  • Loading branch information
mshcherbina committed Jan 20, 2022
1 parent ed7693d commit d8f808e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/SingleStoreConnector/Core/ServerSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ public void FinishQuerying()
// KILL QUERY will kill a subsequent query if the command it was intended to cancel has already completed.
// In order to handle this case, we issue a dummy query that will consume the pending cancellation.
// See https://bugs.mysql.com/bug.php?id=45679
Log.Debug("Session{0} sending 'DO SLEEP(0)' command to clear pending cancellation", m_logArguments);
var payload = QueryPayload.Create(SupportsQueryAttributes, "DO SLEEP(0);");
Log.Debug("Session{0} sending 'SELECT SLEEP(0) INTO @dummy' command to clear pending cancellation", m_logArguments);
var payload = QueryPayload.Create(SupportsQueryAttributes, "SELECT SLEEP(0) INTO @dummy;");
#pragma warning disable CA2012 // Safe because method completes synchronously
SendAsync(payload, IOBehavior.Synchronous, CancellationToken.None).GetAwaiter().GetResult();
payload = ReceiveReplyAsync(IOBehavior.Synchronous, CancellationToken.None).GetAwaiter().GetResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public async Task RunAsync(TcpClient client, CancellationToken token)
m_server.CancelQuery(connectionId);
await SendAsync(stream, 1, WriteOk);
}
else if (query == "DO SLEEP(0);")
else if (query == "SELECT SLEEP(0) INTO @dummy;")
{
var wasSet = CancelQueryEvent.Wait(0, token);
await SendAsync(stream, 1, WriteOk);
Expand Down
4 changes: 2 additions & 2 deletions tests/SideBySide/TransactionScopeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -647,11 +647,11 @@ public async Task CommandBehaviorCloseConnection(string connectionString)
[MemberData(nameof(ConnectionStrings))]
public async Task CancelExecuteNonQueryAsync(string connectionString)
{
using var connection = new SingleStoreConnection(AppConfig.ConnectionString + ";" + connectionString);
using var connection = new SingleStoreConnection(AppConfig.ConnectionString + ";" + connectionString + ";AllowUserVariables=True");
using var transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);
await connection.OpenAsync();

using var command = new SingleStoreCommand("DO SLEEP(3);", connection);
using var command = new SingleStoreCommand("SELECT SLEEP(3) INTO @dummy", connection);
using var tokenSource = new CancellationTokenSource(TimeSpan.FromMilliseconds(100));
await command.ExecuteNonQueryAsync(tokenSource.Token);
}
Expand Down

0 comments on commit d8f808e

Please sign in to comment.