Bug #116146 OpenAsync (of MySqlConnection) throws exception when UseCompression = true
Submitted: 18 Sep 2024 13:16 Modified: 17 Feb 9:54
Reporter: Yitzhak Shmuel Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:9.2.0 OS:Windows (Windows 10 Enterprise)
Assigned to: Omar Chavez CPU Architecture:Any

[18 Sep 2024 13:16] Yitzhak Shmuel
Description:
Hi,

When calling the OpenAsync method of MySqlConnection, when the UseCompression of MySqlConnectionStringBuilder is set to true, a "EndOfStreamException: Attempted to read past the end of the stream" exception is thrown.

Using the Open method instead of the OpenAsync method works as expected.
Also, setting the UseCompression to false works as expected as well.

I'm using VS2022, dotnet 8, MySql.Data nuget package, version 9.0.0.

Thanks

How to repeat:
using MySql.Data.MySqlClient;

internal class Program
{
    private static async Task<int> Main(string[] args)
    {        
        var cancellationToken = new CancellationToken();
        var mySqlConnectionStringBuilder = new MySqlConnectionStringBuilder
        {          
            UserID = "userid", Password = "pass", Server = "server", Port = 3306, Database = "db",
            UseCompression = true
        };

        await using (var dbConnection = new MySqlConnection(mySqlConnectionStringBuilder.ConnectionString))
        {
            await dbConnection.OpenAsync(cancellationToken);
            await using (MySqlCommand queryCommand = new MySqlCommand("SELECT 1", dbConnection))
            {
                var res = await queryCommand.ExecuteNonQueryAsync(cancellationToken);
            }
        }

        return 0;
    }
}
[4 Oct 2024 9:37] MySQL Verification Team
Hi Mr. Shmuel,

Thank you for your bug report.

It is supposed that this bug is fixed in 9.0.1.

Can you, please, try using C/Python 9.0.1 with MySQL Server 9.0.1 and let us know the results.

Thanks in advance.
[4 Oct 2024 9:47] MySQL Verification Team
Hi Mr. Shmuel,

Please also read the following chapter from our manual:

https://dev.mysql.com/doc/refman/9.0/en/connection-compression-control.html

It should be quite useful to you .....
[4 Oct 2024 9:52] MySQL Verification Team
Hi Mr. Shmuel,

You can also find this page helpful:

https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html
[6 Oct 2024 11:22] Yitzhak Shmuel
Hi,

Thanks for your response. 
Unfortunately I have no knowledge in C or Phyton, and a very limited time to try to perform the experiment that you suggested with those packages.
I'll wait for the release of 9.0.1 and see if the issue was resolved.

Thanks,
Yitzhak Shmuel
[7 Oct 2024 9:42] MySQL Verification Team
Hi Mr. Shmuel,

We shall wait on your feedback.
[8 Nov 2024 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[8 Nov 2024 5:37] MySQL Verification Team
Tested Connector/NET 9.1.0 from NuGet.  Verified something is not right when usding compression.

On my system, the compressed connection hangs.
Disabling compression works fine.  SSL had no impact.

I even changed the code to be:

var dbConnection = new MySqlConnection(mySqlConnectionStringBuilder.ConnectionString);
await dbConnection.OpenAsync(cancellationToken);
MySqlCommand queryCommand = new MySqlCommand("SELECT 1", dbConnection);
var res = await queryCommand.ExecuteNonQueryAsync(cancellationToken);

-- 
Shane, MySQL Senior Principal Technical Support Engineer
Oracle Corporation
http://dev.mysql.com/
[19 Nov 2024 13:49] Yitzhak Shmuel
Hi, The problem still exists in 9.1.0, Thanks
[17 Feb 9:04] Yitzhak Shmuel
MySql.Data9.2.0 - exception and stack trace

Attachment: MySql.Data.9.2.0-ExceptionStackTrace.png (image/png, text), 52.04 KiB.

[17 Feb 9:54] Yitzhak Shmuel
Hi, 

The problem still occurs in version 9.2.0.
I'm getting "Fatal error encountered during command execution" with this version.
I attached a screenshot of the exception and the stack trace.

I used the same code as before for the testing.

Thanks