Skip to content

Commit d2ebf2a

Browse files
committed
Change logging from Info to Debug. Fixes #956
The new background connection reset code in 1.3.0 caused two new "Info" log messages for each connection retrieved from the pool. The ping message would have been logged when ConnectionReset=false, but that was not the default behaviour.
1 parent 8cb1eb7 commit d2ebf2a

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

src/MySqlConnector/Core/BackgroundConnectionResetHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static async Task ReturnSessionsAsync()
7777
try
7878
{
7979
// block until AddSession releases the semaphore
80-
Log.Info("Waiting for semaphore.");
80+
Log.Debug("Waiting for semaphore.");
8181
await s_semaphore.WaitAsync(s_cancellationTokenSource.Token).ConfigureAwait(false);
8282

8383
// process all sessions that have started being returned

src/MySqlConnector/Core/ConnectionPool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public async ValueTask<ServerSession> GetSessionAsync(MySqlConnection connection
7272
}
7373
else if ((unchecked((uint) Environment.TickCount) - session.LastReturnedTicks) >= ConnectionSettings.ConnectionIdlePingTime)
7474
{
75-
reuseSession = await session.TryPingAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
75+
reuseSession = await session.TryPingAsync(logInfo: false, ioBehavior, cancellationToken).ConfigureAwait(false);
7676
}
7777
else
7878
{

src/MySqlConnector/Core/ServerSession.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ private async Task<string> GetRsaPublicKeyAsync(string switchRequestName, Connec
745745
}
746746
#endif
747747

748-
public async ValueTask<bool> TryPingAsync(IOBehavior ioBehavior, CancellationToken cancellationToken)
748+
public async ValueTask<bool> TryPingAsync(bool logInfo, IOBehavior ioBehavior, CancellationToken cancellationToken)
749749
{
750750
VerifyState(State.Connected);
751751

@@ -756,7 +756,10 @@ public async ValueTask<bool> TryPingAsync(IOBehavior ioBehavior, CancellationTok
756756
await SendAsync(PingPayload.Instance, ioBehavior, cancellationToken).ConfigureAwait(false);
757757
var payload = await ReceiveReplyAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
758758
OkPayload.Create(payload.Span, SupportsDeprecateEof, SupportsSessionTrack);
759-
Log.Info("Session{0} successfully pinged server", m_logArguments);
759+
if (logInfo)
760+
Log.Info("Session{0} successfully pinged server", m_logArguments);
761+
else
762+
Log.Debug("Session{0} successfully pinged server", m_logArguments);
760763
return true;
761764
}
762765
catch (IOException ex)

src/MySqlConnector/MySqlConnection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ private async ValueTask<bool> PingAsync(IOBehavior ioBehavior, CancellationToken
366366
return false;
367367
try
368368
{
369-
if (await m_session.TryPingAsync(ioBehavior, cancellationToken).ConfigureAwait(false))
369+
if (await m_session.TryPingAsync(logInfo: true, ioBehavior, cancellationToken).ConfigureAwait(false))
370370
return true;
371371
}
372372
catch (InvalidOperationException)

0 commit comments

Comments
 (0)