File tree Expand file tree Collapse file tree 4 files changed +24
-4
lines changed
tests/MySqlConnector.Tests Expand file tree Collapse file tree 4 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ internal static class EventIds
2525 public const int ExpectedToReadMoreBytes = 2010 ;
2626 public const int ExpectedSessionState1 = 2011 ;
2727 public const int ExpectedSessionState6 = 2016 ;
28+ public const int ResettingConnectionFailed = 2017 ;
29+ public const int ResetConnection = 2018 ;
2830
2931 // Session connecting events, 2100-2199
3032 public const int ConnectingFailed = 2100 ;
Original file line number Diff line number Diff line change @@ -28,6 +28,12 @@ internal static partial class Log
2828 [ LoggerMessage ( EventIds . ResettingConnection , LogLevel . Debug , "Session {SessionId} resetting connection" ) ]
2929 public static partial void ResettingConnection ( ILogger logger , string sessionId ) ;
3030
31+ [ LoggerMessage ( EventIds . ResettingConnectionFailed , LogLevel . Warning , "Session {SessionId} failed to reset connection: {Message}" ) ]
32+ public static partial void ResettingConnectionFailed ( ILogger logger , string sessionId , string message ) ;
33+
34+ [ LoggerMessage ( EventIds . ResetConnection , LogLevel . Debug , "Session {SessionId} reset connection" ) ]
35+ public static partial void ResetConnection ( ILogger logger , string sessionId ) ;
36+
3137 [ LoggerMessage ( EventIds . ReturningToPool , LogLevel . Trace , "Session {SessionId} returning to pool {PoolId}" ) ]
3238 public static partial void ReturningToPool ( ILogger logger , string sessionId , int poolId ) ;
3339
Original file line number Diff line number Diff line change @@ -613,9 +613,21 @@ public async ValueTask ResetConnectionAsync(CancellationToken cancellationToken
613613 {
614614 var session = Session ;
615615 Log . ResettingConnection ( m_logger , session . Id ) ;
616- await session . SendAsync ( ResetConnectionPayload . Instance , AsyncIOBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
617- var payload = await session . ReceiveReplyAsync ( AsyncIOBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
618- OkPayload . Verify ( payload . Span , session ) ;
616+ try
617+ {
618+ await session . SendAsync ( ResetConnectionPayload . Instance , AsyncIOBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
619+ var payload = await session . ReceiveReplyAsync ( AsyncIOBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
620+ OkPayload . Verify ( payload . Span , session ) ;
621+ Log . ResetConnection ( m_logger , session . Id ) ;
622+ }
623+ catch ( Exception ex )
624+ {
625+ Log . ResettingConnectionFailed ( m_logger , session . Id , ex . Message ) ;
626+ if ( ex is MySqlException )
627+ throw ;
628+ else
629+ throw new MySqlException ( "Failed to reset connection" , ex ) ;
630+ }
619631 }
620632
621633 [ AllowNull ]
Original file line number Diff line number Diff line change @@ -321,7 +321,7 @@ public async Task ResetServerConnectionWhileOpen()
321321 }
322322 case 2 :
323323 {
324- await Assert . ThrowsAnyAsync < Exception > ( async ( ) => await connection . ResetConnectionAsync ( ) . ConfigureAwait ( false ) ) ;
324+ await Assert . ThrowsAsync < MySqlException > ( async ( ) => await connection . ResetConnectionAsync ( ) . ConfigureAwait ( false ) ) ;
325325 break ;
326326 }
327327 }
You can’t perform that action at this time.
0 commit comments