Skip to content

Commit 8ba116b

Browse files
committed
Handle ER_CLIENT_INTERACTION_TIMEOUT. Fixes #970
This is a new error reported from MySQL Server 8.0.24 when wait_timeout has been exceeded; it should transition the session state to failed.
1 parent c230709 commit 8ba116b

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/MySqlConnector/Core/ServerSession.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,10 @@ public async Task<bool> TryResetConnectionAsync(ConnectionSettings cs, IOBehavio
584584
{
585585
Log.Debug(ex, "Session{0} ignoring IOException in TryResetConnectionAsync", m_logArguments);
586586
}
587+
catch (MySqlException ex) when (ex.ErrorCode == MySqlErrorCode.ClientInteractionTimeout)
588+
{
589+
Log.Debug(ex, "Session{0} ignoring ClientInteractionTimeout MySqlException in TryResetConnectionAsync", m_logArguments);
590+
}
587591
catch (ObjectDisposedException ex)
588592
{
589593
Log.Debug(ex, "Session{0} ignoring ObjectDisposedException in TryResetConnectionAsync", m_logArguments);
@@ -795,6 +799,10 @@ public async ValueTask<bool> TryPingAsync(bool logInfo, IOBehavior ioBehavior, C
795799
{
796800
Log.Debug(ex, "Session{0} ping failed due to IOException", m_logArguments);
797801
}
802+
catch (MySqlException ex) when (ex.ErrorCode == MySqlErrorCode.ClientInteractionTimeout)
803+
{
804+
Log.Debug(ex, "Session{0} ping failed due to ClientInteractionTimeout MySqlException", m_logArguments);
805+
}
798806
catch (SocketException ex)
799807
{
800808
Log.Debug(ex, "Session{0} ping failed due to SocketException", m_logArguments);
@@ -1584,7 +1592,6 @@ private static void SafeDispose<T>(ref T? disposable)
15841592

15851593
internal void SetFailed(Exception exception)
15861594
{
1587-
m_logArguments[1] = exception.Message;
15881595
Log.Info(exception, "Session{0} setting state to Failed", m_logArguments);
15891596
lock (m_lock)
15901597
m_state = State.Failed;
@@ -1677,7 +1684,10 @@ private Exception CreateExceptionForErrorPayload(ReadOnlySpan<byte> span)
16771684
var errorPayload = ErrorPayload.Create(span);
16781685
if (Log.IsDebugEnabled())
16791686
Log.Debug("Session{0} got error payload: Code={1}, State={2}, Message={3}", m_logArguments[0], errorPayload.ErrorCode, errorPayload.State, errorPayload.Message);
1680-
return errorPayload.ToException();
1687+
var exception = errorPayload.ToException();
1688+
if (exception.ErrorCode is MySqlErrorCode.ClientInteractionTimeout)
1689+
SetFailed(exception);
1690+
return exception;
16811691
}
16821692

16831693
private void ClearPreparedStatements()

src/MySqlConnector/MySqlErrorCode.g.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3230,5 +3230,10 @@ public enum MySqlErrorCode
32303230
/// ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION
32313231
/// </summary>
32323232
CannotExecuteInReadOnlyTransaction = 1792,
3233+
3234+
/// <summary>
3235+
/// ER_CLIENT_INTERACTION_TIMEOUT
3236+
/// </summary>
3237+
ClientInteractionTimeout = 4031
32333238
}
32343239
}

0 commit comments

Comments
 (0)