Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySqlConnector.MySqlProtocolException: Packet received out-of-order. Expected 2; got 1. #1465

Open
justdoitang opened this issue Mar 19, 2024 · 11 comments

Comments

@justdoitang
Copy link

justdoitang commented Mar 19, 2024

Software versions
MySqlConnector version:2.2.7
Server type (MySQL, MariaDB, Aurora, etc.) and version: MySQL 8.0
.NET version: .net core 3.1
(Optional) ORM NuGet packages and versions: Dapper 2.1.35

Describe the bug
MySqlConnector.MySqlProtocolException: Packet received out-of-order. Expected 2; got 1.

Exception

 at MySqlConnector.Protocol.Serialization.ProtocolUtility.<DoReadPayloadAsync>g__AddContinuation|5_0(ValueTask`1 readPacketTask, BufferedByteReader bufferedByteReader, IByteHandler byteHandler, Func`1 getNextSequenceNumber, ArraySegmentHolder`1 previousPayloads, ProtocolErrorBehavior protocolErrorBehavior, IOBehavior ioBehavior) in /_/src/MySqlConnector/Protocol/Serialization/ProtocolUtility.cs:line 498

   at MySqlConnector.Core.ServerSession.ReceiveReplyAsyncAwaited(ValueTask`1 task) in /_/src/MySqlConnector/Core/ServerSession.cs:line 968

   at MySqlConnector.Core.ServerSession.TryResetConnectionAsync(ConnectionSettings cs, MySqlConnection connection, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ServerSession.cs:line 700

   at MySqlConnector.Core.ConnectionPool.GetSessionAsync(MySqlConnection connection, Int32 startTickCount, Int32 timeoutMilliseconds, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ConnectionPool.cs:line 137

   at MySqlConnector.Core.ConnectionPool.GetSessionAsync(MySqlConnection connection, Int32 startTickCount, Int32 timeoutMilliseconds, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ConnectionPool.cs:line 137

   at MySqlConnector.MySqlConnection.CreateSessionAsync(ConnectionPool pool, Int32 startTickCount, Activity activity, Nullable`1 ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlConnection.cs:line 966

   at MySqlConnector.MySqlConnection.OpenAsync(Nullable`1 ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlConnection.cs:line 457

   at MySqlConnector.MySqlConnection.Open() in /_/src/MySqlConnector/MySqlConnection.cs:line 382

Code sample
image

@EmaX093
Copy link

EmaX093 commented May 13, 2024

Same problem here, had to revert to from 2.3.7 to 2.3.5 and the problem is gone. I tested 2.3.6 and problem occurs too. Something changed since 2.3.6.

My setup is: Linq2DB 5.4.1 + MySQL InnoDB Cluster 8.0.35 + ProxySQL version 2.5.5-10-g195bd70, codename Truls.

@Ekkeir
Copy link

Ekkeir commented Jul 9, 2024

We've also observed Packet received out-of-order. Expected 2; got 1. error with MySqlConnector versions 2.3.6, 2.3.7.
Adding Pipelining = False; to connection string (as mentioned in Release notes) resolved the issue, yet breaking changes like this in minor updates seem undesirable.

MariaDB (ver. 10.6.16-MariaDB-log)
MySqlConnector versions: 2.3.6, 2.3.7

@bgrainger
Copy link
Member

Is this problem reproducible? Is it possible to provide a packet capture from when the problem occurs?

@wjl476146955
Copy link

wjl476146955 commented Jul 24, 2024

Same problem happened. 2.3.7 or 2.3.6 and mysql8.0.26 throw error "MySqlConnector.MySqlProtocolException: Packet received out-of-order. Expected 1; got 2." 2.2.5 is ok.

@EmaX093
Copy link

EmaX093 commented Aug 19, 2024

Is this problem reproducible? Is it possible to provide a packet capture from when the problem occurs?

This is what you need ?
ddd.txt

@EmaX093
Copy link

EmaX093 commented Aug 19, 2024

We've also observed Packet received out-of-order. Expected 2; got 1. error with MySqlConnector versions 2.3.6, 2.3.7. Adding Pipelining = False; to connection string (as mentioned in Release notes) resolved the issue, yet breaking changes like this in minor updates seem undesirable.

MariaDB (ver. 10.6.16-MariaDB-log) MySqlConnector versions: 2.3.6, 2.3.7

This totally fix the problem for me! Thank you!

@bgrainger
Copy link
Member

bgrainger commented Aug 20, 2024

This is what you need ?
ddd.txt

That file shows:

-> Packet Number: 0, Statement: set session transaction isolation level repeatable read;
-> Packet Number: 0, Statement: start transaction;
<- Packet Number: 1, Response Code: OK Packet (0x00) 
<- Packet Number: 2, Response Code: OK Packet (0x00) 

This is an incorrect response from the MySQL Server and is causing the error.

Adding Pipelining = False; to connection string

That is also what I would recommend given the observed behavior above.

@bgrainger
Copy link
Member

@EmaX093

You've mentioned both of these MySQL Servers in different comments:

My setup is: Linq2DB 5.4.1 + MySQL InnoDB Cluster 8.0.35 + ProxySQL version 2.5.5-10-g195bd70, codename Truls.

MariaDB (ver. 10.6.16-MariaDB-log)

Are you using both of them? Do both exhibit the "Packet received out-of-order" problem?

@EmaX093
Copy link

EmaX093 commented Aug 20, 2024

@EmaX093

You've mentioned both of these MySQL Servers in different comments:

My setup is: Linq2DB 5.4.1 + MySQL InnoDB Cluster 8.0.35 + ProxySQL version 2.5.5-10-g195bd70, codename Truls.

MariaDB (ver. 10.6.16-MariaDB-log)

Are you using both of them? Do both exhibit the "Packet received out-of-order" problem?

Hello! That was the other guy, I only have MySQL InnoDB Cluster with a proxysql in front.

Anyway i just tried to connect directly to mysql without proxysql and it works just fine so is a problem related to proxysql.

Thank you for your time and I apologize for the inconveniences.

@Quaybe
Copy link

Quaybe commented Sep 17, 2024

Just here to say that I'm having the exact same issue. Our MySql servers are in a cluster environment, for what it's worth. Adding Pipelining = False to connection string corrects the issue for me.

@completej
Copy link

Just here to say that I'm having the exact same issue. Our MySql servers are in a cluster environment, for what it's worth. Adding Pipelining = False to connection string corrects the issue for me.

Adding to this. Our DEV tier is a single node instance with no issues @ 2.3.7. Our UAT and PRD tiers are 3-node Galera clusters that saw compatibility issues. Adding Pipelining = False; also fixed this for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

7 participants