GithubHelp home page GithubHelp logo

Comments (4)

bgrainger avatar bgrainger commented on June 14, 2024 1

For efficiency in the typical use case, perhaps we could only SHOW VARIABLES once a SQL statement larger than 4MB (the MySQL Server default) has been prepared in the client?

from mysqlconnector.

caleblloyd avatar caleblloyd commented on June 14, 2024 1

What about cases where the client has upped it's max_allowed_packet size before sending a large packet, but after we theoretically record max_allowed_packet? We would reject a query client-side that would have succeeded.

mysql> SELECT @@global.max_allowed_packet;
+-----------------------------+
| @@global.max_allowed_packet |
+-----------------------------+
|                     4194304 |
+-----------------------------+
1 row in set (0.00 sec)

mysql> SET @@global.max_allowed_packet = 8388608;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT @@global.max_allowed_packet;
+-----------------------------+
| @@global.max_allowed_packet |
+-----------------------------+
|                     8388608 |
+-----------------------------+
1 row in set (0.00 sec)

Maybe a better approach is to record number of bytes sent in the packet, and throw an Outer Exception if packet size was > 4MB with "Exception after submitting XXMB Packet, ensure max_allowed_packet is greater than XXMB" -> Inner Exception (original exception)

from mysqlconnector.

bgrainger avatar bgrainger commented on June 14, 2024

MySQL Server does send a final packet with the contents #08S01, Got a packet bigger than 'max_allowed_packet' bytes but then it immediately resets the socket. As a result, our library throws a SocketException ("An existing connection was forcibly closed by the remote host" or "An established connection was aborted by the software in your host machine") when trying to read that packet in:

System.dll!System.Net.Sockets.Socket.Receive(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags)	Unknown
MySqlConnector.dll!MySql.Data.Protocol.Serialization.SocketByteHandler.ReadBytesAsync(System.ArraySegment<byte> buffer, MySql.Data.Protocol.Serialization.IOBehavior ioBehavior) Line 24	C#
MySqlConnector.dll!MySql.Data.Protocol.Serialization.BufferedByteReader.ReadBytesAsync(MySql.Data.Protocol.Serialization.IByteHandler byteHandler, System.ArraySegment<byte> buffer, int count, MySql.Data.Protocol.Serialization.IOBehavior ioBehavior) Line 34	C#
MySqlConnector.dll!MySql.Data.Protocol.Serialization.BufferedByteReader.ReadBytesAsync(MySql.Data.Protocol.Serialization.IByteHandler byteHandler, int count, MySql.Data.Protocol.Serialization.IOBehavior ioBehavior) Line 29	C#
MySqlConnector.dll!MySql.Data.Protocol.Serialization.ProtocolUtility.ReadPacketAsync(MySql.Data.Protocol.Serialization.BufferedByteReader bufferedByteReader, MySql.Data.Protocol.Serialization.IByteHandler byteHandler, System.Func<int?> getNextSequenceNumber, MySql.Data.Protocol.Serialization.ProtocolErrorBehavior protocolErrorBehavior, MySql.Data.Protocol.Serialization.IOBehavior ioBehavior) Line 13	C#
MySqlConnector.dll!MySql.Data.Protocol.Serialization.ProtocolUtility.ReadPayloadAsync(MySql.Data.Protocol.Serialization.BufferedByteReader bufferedByteReader, MySql.Data.Protocol.Serialization.IByteHandler byteHandler, System.Func<int?> getNextSequenceNumber, System.ArraySegment<byte> previousPayloads, MySql.Data.Protocol.Serialization.ProtocolErrorBehavior protocolErrorBehavior, MySql.Data.Protocol.Serialization.IOBehavior ioBehavior) Line 53	C#
MySqlConnector.dll!MySql.Data.Protocol.Serialization.StandardPayloadHandler.ReadPayloadAsync(MySql.Data.Protocol.Serialization.ProtocolErrorBehavior protocolErrorBehavior, MySql.Data.Protocol.Serialization.IOBehavior ioBehavior) Line 31	C#
MySqlConnector.dll!MySql.Data.Serialization.MySqlSession.TryAsync(System.Func<MySql.Data.Protocol.Serialization.ProtocolErrorBehavior, MySql.Data.Protocol.Serialization.IOBehavior, System.Threading.Tasks.ValueTask<System.ArraySegment<byte>>> func, MySql.Data.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) Line 471	C#
MySqlConnector.dll!MySql.Data.Serialization.MySqlSession.ReceiveReplyAsync(MySql.Data.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) Line 187	C#
MySqlConnector.dll!MySql.Data.MySqlClient.Results.ResultSet.ReadResultSetHeaderAsync(MySql.Data.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) Line 37	C#
MySqlConnector.dll!MySql.Data.MySqlClient.MySqlDataReader.ReadFirstResultSetAsync(MySql.Data.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) Line 239	C#
MySqlConnector.dll!MySql.Data.MySqlClient.MySqlDataReader.CreateAsync(MySql.Data.MySqlClient.MySqlCommand command, System.Data.CommandBehavior behavior, MySql.Data.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) Line 227	C#
MySqlConnector.dll!MySql.Data.MySqlClient.CommandExecutors.TextCommandExecutor.ExecuteReaderAsync(string commandText, MySql.Data.MySqlClient.MySqlParameterCollection parameterCollection, System.Data.CommandBehavior behavior, MySql.Data.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) Line 59	C#
MySqlConnector.dll!MySql.Data.MySqlClient.MySqlCommand.ExecuteReaderAsync(System.Data.CommandBehavior behavior, MySql.Data.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) Line 143	C#
MySqlConnector.dll!MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(System.Data.CommandBehavior behavior) Line 116	C#
System.Data.dll!System.Data.Common.DbCommand.ExecuteReader()	Unknown

from mysqlconnector.

bgrainger avatar bgrainger commented on June 14, 2024

Fixed in 0.16.1.

from mysqlconnector.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.