The following code throws a SocketException that obscures the real exception (MySqlException: Got a packet bigger than 'max_allowed_packet' bytes):
using var connection = new MySqlConnection(ConnectionString);
connection.Open();
using var transaction = connection.BeginTransaction();
connection.Execute("insert into bigblobs(`data`) values(@data);", new { data = new byte[LARGE_NUMBER] }, transaction);
The exception that's thrown is:
Unhandled exception. System.Net.Sockets.SocketException (10053): An established connection was aborted by the software in your host machine.
at System.Net.Sockets.Socket.Send(ReadOnlySpan`1 buffer, SocketFlags socketFlags)
at MySqlConnector.Utilities.SocketExtensions.Send(Socket socket, ReadOnlyMemory`1 data, SocketFlags flags) in C:\Code\MySql\MySqlConnector\src\MySqlConnector\Utilities\SocketExtensions.cs:line 40
at MySqlConnector.Protocol.Serialization.SocketByteHandler.WriteBytesAsync(ReadOnlyMemory`1 data, IOBehavior ioBehavior) in C:\Code\MySql\MySqlConnector\src\MySqlConnector\Protocol\Serialization\SocketByteHandler.cs:line 115
--- End of stack trace from previous location ---
at MySqlConnector.Protocol.Serialization.ProtocolUtility.<WritePacketAsync>g__WritePacketAsyncAwaited|8_0(ValueTask`1 task_, Byte[] buffer_) in C:\Code\MySql\MySqlConnector\src\MySqlConnector\Protocol\Serialization\ProtocolUtility.cs:line 546
at MySqlConnector.Core.ServerSession.SendReplyAsyncAwaited(ValueTask`1 task) in C:\Code\MySql\MySqlConnector\src\MySqlConnector\Core\ServerSession.cs:line 844
at MySqlConnector.Core.CommandExecutor.ExecuteReaderAsync(IReadOnlyList`1 commands, ICommandPayloadCreator payloadCreator, CommandBehavior behavior, IOBehavior ioBehavior, CancellationToken cancellationToken) in C:\Code\MySql\MySqlConnector\src\MySqlConnector\Core\CommandExecutor.cs:line 59
at MySqlConnector.MySqlCommand.ExecuteNonQueryAsync(IOBehavior ioBehavior, CancellationToken cancellationToken) in C:\Code\MySql\MySqlConnector\src\MySqlConnector\MySqlCommand.cs:line 264
at MySqlConnector.MySqlTransaction.DoDisposeAsync(IOBehavior ioBehavior, CancellationToken cancellationToken) in C:\Code\MySql\MySqlConnector\src\MySqlConnector\MySqlTransaction.cs:line 232
at MySqlConnector.MySqlTransaction.Dispose(Boolean disposing) in C:\Code\MySql\MySqlConnector\src\MySqlConnector\MySqlTransaction.cs:line 184
at System.Data.Common.DbTransaction.Dispose()
MySqlTransaction.Dispose should not throw an exception, as it obscures the real exception that's causing the call stack to be unwound.
The following code throws a
SocketExceptionthat obscures the real exception (MySqlException: Got a packet bigger than 'max_allowed_packet' bytes):The exception that's thrown is:
MySqlTransaction.Dispose should not throw an exception, as it obscures the real exception that's causing the call stack to be unwound.