Skip to content

Commit f26ae9b

Browse files
committed
Swallow and log exceptions in MySqlDataReader.Dispose.
1 parent cae8714 commit f26ae9b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/MySqlConnector/MySqlDataReader.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Diagnostics;
44
using System.Globalization;
55
using MySqlConnector.Core;
6+
using MySqlConnector.Logging;
67
using MySqlConnector.Protocol.Serialization;
78
using MySqlConnector.Utilities;
89

@@ -610,9 +611,11 @@ internal async Task DisposeAsync(IOBehavior ioBehavior, CancellationToken cancel
610611
{
611612
}
612613
}
613-
catch (MySqlException ex) when (ex.ErrorCode == MySqlErrorCode.QueryInterrupted)
614+
catch (MySqlException ex)
614615
{
615-
// ignore "Query execution was interrupted" exceptions when closing a data reader
616+
// ignore "Query execution was interrupted" exceptions when closing a data reader; log other exceptions
617+
if (ex.ErrorCode != MySqlErrorCode.QueryInterrupted)
618+
Log.Warn("Session{0} ignoring exception in MySqlDataReader.DisposeAsync. Message: {1}. CommandText: {2}", Command.Connection.Session.Id, ex.Message, Command.CommandText);
616619
}
617620
m_resultSet = null;
618621
}
@@ -678,6 +681,8 @@ private ResultSet GetResultSet()
678681
return m_resultSet;
679682
}
680683

684+
private static readonly IMySqlConnectorLogger Log = MySqlConnectorLogManager.CreateLogger(nameof(MySqlDataReader));
685+
681686
private readonly CommandBehavior m_behavior;
682687
private readonly ICommandPayloadCreator m_payloadCreator;
683688
private readonly IDictionary<string, CachedProcedure?>? m_cachedProcedures;

0 commit comments

Comments
 (0)