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

MySqlTransaction.Dispose throws exception #923

bgrainger opened this issue Jan 5, 2021 · 1 comment

MySqlTransaction.Dispose throws exception #923

bgrainger opened this issue Jan 5, 2021 · 1 comment


Copy link

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);
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.

@bgrainger bgrainger added the bug label Jan 5, 2021
@bgrainger bgrainger self-assigned this Jan 5, 2021
Copy link
Member Author

Fixed in 1.3.0.

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

No branches or pull requests

1 participant