Skip to content

Commit 996f269

Browse files
committed
Revert "Optimise reset connection." Fixes #486
Pipelining the packets was not supported by Amazon Aurora. This reverts commit be19393.
1 parent fa2ce4d commit 996f269

File tree

2 files changed

+7
-31
lines changed

2 files changed

+7
-31
lines changed

src/MySqlConnector/Core/ServerSession.cs

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -362,31 +362,14 @@ public async Task<bool> TryResetConnectionAsync(ConnectionSettings cs, IOBehavio
362362
{
363363
m_logArguments[1] = ServerVersion.OriginalString;
364364
Log.Debug("Session{0} ServerVersion={1} supports reset connection; sending reset connection request", m_logArguments);
365-
if (m_payloadHandler is StandardPayloadHandler standardPayloadHandler)
366-
{
367-
// send both packets at once
368-
await standardPayloadHandler.ByteHandler.WriteBytesAsync(s_resetConnectionPackets, ioBehavior).ConfigureAwait(false);
369-
370-
// read two OK replies
371-
standardPayloadHandler.SetNextSequenceNumber(1);
372-
var payload = await ReceiveReplyAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
373-
OkPayload.Create(payload);
365+
await SendAsync(ResetConnectionPayload.Instance, ioBehavior, cancellationToken).ConfigureAwait(false);
366+
var payload = await ReceiveReplyAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
367+
OkPayload.Create(payload);
374368

375-
standardPayloadHandler.SetNextSequenceNumber(1);
376-
payload = await ReceiveReplyAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
377-
OkPayload.Create(payload);
378-
}
379-
else
380-
{
381-
await SendAsync(ResetConnectionPayload.Instance, ioBehavior, cancellationToken).ConfigureAwait(false);
382-
var payload = await ReceiveReplyAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
383-
OkPayload.Create(payload);
384-
385-
// the "reset connection" packet also resets the connection charset, so we need to change that back to our default
386-
await SendAsync(s_setNamesUtf8mb4Payload, ioBehavior, cancellationToken).ConfigureAwait(false);
387-
payload = await ReceiveReplyAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
388-
OkPayload.Create(payload);
389-
}
369+
// the "reset connection" packet also resets the connection charset, so we need to change that back to our default
370+
await SendAsync(s_setNamesUtf8mb4Payload, ioBehavior, cancellationToken).ConfigureAwait(false);
371+
payload = await ReceiveReplyAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
372+
OkPayload.Create(payload);
390373
}
391374
else
392375
{
@@ -1219,11 +1202,6 @@ private enum State
12191202
static byte[] s_connectionAttributes;
12201203
static readonly IMySqlConnectorLogger Log = MySqlConnectorLogManager.CreateLogger(nameof(ServerSession));
12211204
static readonly PayloadData s_setNamesUtf8mb4Payload = QueryPayload.Create("SET NAMES utf8mb4 COLLATE utf8mb4_bin;");
1222-
static readonly ArraySegment<byte> s_resetConnectionPackets = new ArraySegment<byte>(new byte[]
1223-
{
1224-
1, 0, 0, 0, (byte) CommandKind.ResetConnection,
1225-
39, 0, 0, 0, (byte) CommandKind.Query, 83, 69, 84, 32, 78, 65, 77, 69, 83, 32, 117, 116, 102, 56, 109, 98, 52, 32, 67, 79, 76, 76, 65, 84, 69, 32, 117, 116, 102, 56, 109, 98, 52, 95, 98, 105, 110, 59 // SET NAMES utf8mb4 COLLATE utf8mb4_bin;
1226-
});
12271205

12281206
readonly object m_lock;
12291207
readonly object[] m_logArguments;

src/MySqlConnector/Protocol/Serialization/StandardPayloadHandler.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ public void StartNewConversation()
2323
m_sequenceNumber = 0;
2424
}
2525

26-
public void SetNextSequenceNumber(int sequenceNumber) => m_sequenceNumber = sequenceNumber;
27-
2826
public IByteHandler ByteHandler
2927
{
3028
get => m_byteHandler;

0 commit comments

Comments
 (0)