Skip to content

Commit 8efdc2e

Browse files
committed
Log exception when setting state to Failed.
1 parent f346d00 commit 8efdc2e

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/MySqlConnector/Core/ServerSession.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ private int TryAsyncContinuation(Task<int> task)
995995
{
996996
if (task.IsFaulted)
997997
{
998-
SetFailed();
998+
SetFailed(task.Exception.InnerException);
999999
task.GetAwaiter().GetResult();
10001000
}
10011001
return 0;
@@ -1004,7 +1004,7 @@ private int TryAsyncContinuation(Task<int> task)
10041004
private PayloadData TryAsyncContinuation(Task<ArraySegment<byte>> task)
10051005
{
10061006
if (task.IsFaulted)
1007-
SetFailed();
1007+
SetFailed(task.Exception.InnerException);
10081008
ArraySegment<byte> bytes;
10091009
try
10101010
{
@@ -1021,9 +1021,10 @@ private PayloadData TryAsyncContinuation(Task<ArraySegment<byte>> task)
10211021
return payload;
10221022
}
10231023

1024-
internal void SetFailed()
1024+
internal void SetFailed(Exception exception)
10251025
{
1026-
Log.Info("{0} setting state to Failed", m_logArguments);
1026+
m_logArguments[1] = exception.Message;
1027+
Log.Info(exception, "{0} setting state to Failed: {1}", m_logArguments);
10271028
lock (m_lock)
10281029
m_state = State.Failed;
10291030
}

src/MySqlConnector/MySql.Data.MySqlClient/MySqlDataReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private void ActivateResultSet(ResultSet resultSet)
9696
// for any exception not created from an ErrorPayload, mark the session as failed (because we can't guarantee that all data
9797
// has been read from the connection and that the socket is still usable)
9898
if (mySqlException?.SqlState == null)
99-
Command.Connection.Session.SetFailed();
99+
Command.Connection.Session.SetFailed(resultSet.ReadResultSetHeaderException);
100100

101101
throw mySqlException != null ?
102102
new MySqlException(mySqlException.Number, mySqlException.SqlState, mySqlException.Message, mySqlException) :

0 commit comments

Comments
 (0)