@@ -28,15 +28,15 @@ public async ValueTask<ServerSession> GetSessionAsync(MySqlConnection connection
28
28
// on the lock in RecoverLeakedSessions in high-concurrency situations
29
29
if ( IsEmpty && unchecked ( ( ( uint ) Environment . TickCount ) - m_lastRecoveryTime ) >= 1000u )
30
30
{
31
- Log . Info ( "Pool{0} is empty; recovering leaked sessions" , m_logArguments ) ;
31
+ Log . Debug ( "Pool{0} is empty; trying to recover any leaked sessions" , m_logArguments ) ;
32
32
await RecoverLeakedSessionsAsync ( ioBehavior ) . ConfigureAwait ( false ) ;
33
33
}
34
34
35
35
if ( ConnectionSettings . MinimumPoolSize > 0 )
36
36
await CreateMinimumPooledSessions ( ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
37
37
38
38
// wait for an open slot (until the cancellationToken is cancelled, which is typically due to timeout)
39
- Log . Debug ( "Pool{0} waiting for an available session" , m_logArguments ) ;
39
+ Log . Trace ( "Pool{0} waiting for an available session" , m_logArguments ) ;
40
40
if ( ioBehavior == IOBehavior . Asynchronous )
41
41
await m_sessionSemaphore . WaitAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
42
42
else
@@ -56,12 +56,12 @@ public async ValueTask<ServerSession> GetSessionAsync(MySqlConnection connection
56
56
}
57
57
if ( session is not null )
58
58
{
59
- Log . Debug ( "Pool{0} found an existing session; checking it for validity" , m_logArguments ) ;
59
+ Log . Trace ( "Pool{0} found an existing session; checking it for validity" , m_logArguments ) ;
60
60
bool reuseSession ;
61
61
62
62
if ( session . PoolGeneration != m_generation )
63
63
{
64
- Log . Debug ( "Pool{0} discarding session due to wrong generation" , m_logArguments ) ;
64
+ Log . Trace ( "Pool{0} discarding session due to wrong generation" , m_logArguments ) ;
65
65
reuseSession = false ;
66
66
}
67
67
else
@@ -83,7 +83,7 @@ public async ValueTask<ServerSession> GetSessionAsync(MySqlConnection connection
83
83
if ( ! reuseSession )
84
84
{
85
85
// session is either old or cannot communicate with the server
86
- Log . Warn ( "Pool{0} Session{1} is unusable; destroying it" , m_logArguments [ 0 ] , session . Id ) ;
86
+ Log . Info ( "Pool{0} Session{1} is unusable; destroying it" , m_logArguments [ 0 ] , session . Id ) ;
87
87
AdjustHostConnectionCount ( session , - 1 ) ;
88
88
await session . DisposeAsync ( ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
89
89
}
@@ -97,8 +97,8 @@ public async ValueTask<ServerSession> GetSessionAsync(MySqlConnection connection
97
97
m_leasedSessions . Add ( session . Id , session ) ;
98
98
leasedSessionsCountPooled = m_leasedSessions . Count ;
99
99
}
100
- if ( Log . IsDebugEnabled ( ) )
101
- Log . Debug ( "Pool{0} returning pooled Session{1} to caller; LeasedSessionsCount={2}" , m_logArguments [ 0 ] , session . Id , leasedSessionsCountPooled ) ;
100
+ if ( Log . IsTraceEnabled ( ) )
101
+ Log . Trace ( "Pool{0} returning pooled Session{1} to caller; LeasedSessionsCount={2}" , m_logArguments [ 0 ] , session . Id , leasedSessionsCountPooled ) ;
102
102
return session ;
103
103
}
104
104
}
@@ -113,8 +113,8 @@ public async ValueTask<ServerSession> GetSessionAsync(MySqlConnection connection
113
113
m_leasedSessions . Add ( session . Id , session ) ;
114
114
leasedSessionsCountNew = m_leasedSessions . Count ;
115
115
}
116
- if ( Log . IsDebugEnabled ( ) )
117
- Log . Debug ( "Pool{0} returning new Session{1} to caller; LeasedSessionsCount={2}" , m_logArguments [ 0 ] , session . Id , leasedSessionsCountNew ) ;
116
+ if ( Log . IsTraceEnabled ( ) )
117
+ Log . Trace ( "Pool{0} returning new Session{1} to caller; LeasedSessionsCount={2}" , m_logArguments [ 0 ] , session . Id , leasedSessionsCountNew ) ;
118
118
return session ;
119
119
}
120
120
catch ( Exception ex )
@@ -129,7 +129,7 @@ public async ValueTask<ServerSession> GetSessionAsync(MySqlConnection connection
129
129
}
130
130
catch ( Exception unexpectedException )
131
131
{
132
- Log . Error ( unexpectedException , "Pool{0} unexpected error in GetSessionAsync: {1}" , m_logArguments [ 0 ] , unexpectedException . Message ) ;
132
+ Log . Warn ( unexpectedException , "Pool{0} unexpected error in GetSessionAsync: {1}" , m_logArguments [ 0 ] , unexpectedException . Message ) ;
133
133
}
134
134
}
135
135
@@ -164,8 +164,8 @@ public async ValueTask ReturnAsync(IOBehavior ioBehavior, ServerSession session)
164
164
public async ValueTask < int > ReturnAsync ( IOBehavior ioBehavior , ServerSession session )
165
165
#endif
166
166
{
167
- if ( Log . IsDebugEnabled ( ) )
168
- Log . Debug ( "Pool{0} receiving Session{1} back" , m_logArguments [ 0 ] , session . Id ) ;
167
+ if ( Log . IsTraceEnabled ( ) )
168
+ Log . Trace ( "Pool{0} receiving Session{1} back" , m_logArguments [ 0 ] , session . Id ) ;
169
169
170
170
try
171
171
{
@@ -181,9 +181,9 @@ public async ValueTask<int> ReturnAsync(IOBehavior ioBehavior, ServerSession ses
181
181
else
182
182
{
183
183
if ( sessionHealth == 1 )
184
- Log . Warn ( "Pool{0} received invalid Session{1}; destroying it" , m_logArguments [ 0 ] , session . Id ) ;
184
+ Log . Info ( "Pool{0} received invalid Session{1}; destroying it" , m_logArguments [ 0 ] , session . Id ) ;
185
185
else
186
- Log . Info ( "Pool{0} received expired Session{1}; destroying it" , m_logArguments [ 0 ] , session . Id ) ;
186
+ Log . Debug ( "Pool{0} received expired Session{1}; destroying it" , m_logArguments [ 0 ] , session . Id ) ;
187
187
AdjustHostConnectionCount ( session , - 1 ) ;
188
188
await session . DisposeAsync ( ioBehavior , CancellationToken . None ) . ConfigureAwait ( false ) ;
189
189
}
@@ -210,7 +210,7 @@ public async Task ClearAsync(IOBehavior ioBehavior, CancellationToken cancellati
210
210
211
211
public async Task ReapAsync ( IOBehavior ioBehavior , CancellationToken cancellationToken )
212
212
{
213
- Log . Debug ( "Pool{0} reaping connection pool" , m_logArguments ) ;
213
+ Log . Trace ( "Pool{0} reaping connection pool" , m_logArguments ) ;
214
214
await RecoverLeakedSessionsAsync ( ioBehavior ) . ConfigureAwait ( false ) ;
215
215
await CleanPoolAsync ( ioBehavior , session => ( unchecked ( ( uint ) Environment . TickCount ) - session . LastReturnedTicks ) / 1000 >= ConnectionSettings . ConnectionIdleTimeout , true , cancellationToken ) . ConfigureAwait ( false ) ;
216
216
}
@@ -250,7 +250,7 @@ private async Task RecoverLeakedSessionsAsync(IOBehavior ioBehavior)
250
250
}
251
251
}
252
252
if ( recoveredSessions . Count == 0 )
253
- Log . Debug ( "Pool{0} recovered no sessions" , m_logArguments ) ;
253
+ Log . Trace ( "Pool{0} recovered no sessions" , m_logArguments ) ;
254
254
else
255
255
Log . Warn ( "Pool{0}: RecoveredSessionCount={1}" , m_logArguments [ 0 ] , recoveredSessions . Count ) ;
256
256
foreach ( var session in recoveredSessions )
@@ -306,7 +306,7 @@ private async Task CleanPoolAsync(IOBehavior ioBehavior, Func<ServerSession, boo
306
306
if ( shouldCleanFn ( session ) )
307
307
{
308
308
// session should be cleaned; dispose it and keep iterating
309
- Log . Info ( "Pool{0} found Session{1} to clean up" , m_logArguments [ 0 ] , session . Id ) ;
309
+ Log . Debug ( "Pool{0} found Session{1} to clean up" , m_logArguments [ 0 ] , session . Id ) ;
310
310
await session . DisposeAsync ( ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
311
311
}
312
312
else
@@ -371,40 +371,40 @@ private async Task CreateMinimumPooledSessions(IOBehavior ioBehavior, Cancellati
371
371
private async ValueTask < ServerSession > ConnectSessionAsync ( string logMessage , int startTickCount , IOBehavior ioBehavior , CancellationToken cancellationToken )
372
372
{
373
373
var session = new ServerSession ( this , m_generation , Interlocked . Increment ( ref m_lastSessionId ) ) ;
374
- if ( Log . IsInfoEnabled ( ) )
375
- Log . Info ( logMessage , m_logArguments [ 0 ] , session . Id ) ;
374
+ if ( Log . IsDebugEnabled ( ) )
375
+ Log . Debug ( logMessage , m_logArguments [ 0 ] , session . Id ) ;
376
376
var statusInfo = await session . ConnectAsync ( ConnectionSettings , startTickCount , m_loadBalancer , ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
377
377
Exception ? redirectionException = null ;
378
378
379
379
if ( statusInfo is not null && statusInfo . StartsWith ( "Location: mysql://" , StringComparison . Ordinal ) )
380
380
{
381
381
// server redirection string has the format "Location: mysql://{host}:{port}/user={userId}[&ttl={ttl}]"
382
- Log . Info ( "Session{0} has server redirection header {1}" , session . Id , statusInfo ) ;
382
+ Log . Trace ( "Session{0} has server redirection header {1}" , session . Id , statusInfo ) ;
383
383
384
384
if ( ConnectionSettings . ServerRedirectionMode == MySqlServerRedirectionMode . Disabled )
385
385
{
386
- Log . Info ( "Pool{0} server redirection is disabled; ignoring redirection" , m_logArguments ) ;
386
+ Log . Trace ( "Pool{0} server redirection is disabled; ignoring redirection" , m_logArguments ) ;
387
387
}
388
388
else if ( Utility . TryParseRedirectionHeader ( statusInfo , out var host , out var port , out var user ) )
389
389
{
390
390
if ( host != ConnectionSettings . HostNames ! [ 0 ] || port != ConnectionSettings . Port || user != ConnectionSettings . UserID )
391
391
{
392
392
var redirectedSettings = ConnectionSettings . CloneWith ( host , port , user ) ;
393
- Log . Info ( "Pool{0} opening new connection to Host={1}; Port={2}; User={3}" , m_logArguments [ 0 ] , host , port , user ) ;
393
+ Log . Debug ( "Pool{0} opening new connection to Host={1}; Port={2}; User={3}" , m_logArguments [ 0 ] , host , port , user ) ;
394
394
var redirectedSession = new ServerSession ( this , m_generation , Interlocked . Increment ( ref m_lastSessionId ) ) ;
395
395
try
396
396
{
397
397
await redirectedSession . ConnectAsync ( redirectedSettings , startTickCount , m_loadBalancer , ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
398
398
}
399
399
catch ( Exception ex )
400
400
{
401
- Log . Warn ( ex , "Pool{0} failed to connect redirected Session{1}" , m_logArguments [ 0 ] , redirectedSession . Id ) ;
401
+ Log . Info ( ex , "Pool{0} failed to connect redirected Session{1}" , m_logArguments [ 0 ] , redirectedSession . Id ) ;
402
402
redirectionException = ex ;
403
403
}
404
404
405
405
if ( redirectionException is null )
406
406
{
407
- Log . Info ( "Pool{0} closing Session{1} to use redirected Session{2} instead" , m_logArguments [ 0 ] , session . Id , redirectedSession . Id ) ;
407
+ Log . Trace ( "Pool{0} closing Session{1} to use redirected Session{2} instead" , m_logArguments [ 0 ] , session . Id , redirectedSession . Id ) ;
408
408
await session . DisposeAsync ( ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
409
409
return redirectedSession ;
410
410
}
@@ -421,7 +421,7 @@ private async ValueTask<ServerSession> ConnectSessionAsync(string logMessage, in
421
421
}
422
422
else
423
423
{
424
- Log . Info ( "Session{0} is already connected to this server; ignoring redirection" , session . Id ) ;
424
+ Log . Trace ( "Session{0} is already connected to this server; ignoring redirection" , session . Id ) ;
425
425
}
426
426
}
427
427
}
@@ -486,9 +486,9 @@ private async ValueTask<ServerSession> ConnectSessionAsync(string logMessage, in
486
486
if ( connectionSettings . ConnectionReset )
487
487
BackgroundConnectionResetHelper . Start ( ) ;
488
488
}
489
- else if ( pool != newPool && Log . IsInfoEnabled ( ) )
489
+ else if ( pool != newPool && Log . IsDebugEnabled ( ) )
490
490
{
491
- Log . Info ( "Pool{0} was created but will not be used (due to race)" , newPool . m_logArguments ) ;
491
+ Log . Debug ( "Pool{0} was created but will not be used (due to race)" , newPool . m_logArguments ) ;
492
492
}
493
493
494
494
return pool ;
0 commit comments