@@ -29,15 +29,15 @@ public async ValueTask<ServerSession> GetSessionAsync(MySqlConnection connection
29
29
// on the lock in RecoverLeakedSessions in high-concurrency situations
30
30
if ( m_sessionSemaphore . CurrentCount == 0 && unchecked ( ( ( uint ) Environment . TickCount ) - m_lastRecoveryTime ) >= 1000u )
31
31
{
32
- Log . Warn ( "{0} is empty; recovering leaked sessions" , m_logArguments ) ;
32
+ Log . Warn ( "Pool {0} is empty; recovering leaked sessions" , m_logArguments ) ;
33
33
RecoverLeakedSessions ( ) ;
34
34
}
35
35
36
36
if ( ConnectionSettings . MinimumPoolSize > 0 )
37
37
await CreateMinimumPooledSessions ( ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
38
38
39
39
// wait for an open slot (until the cancellationToken is cancelled, which is typically due to timeout)
40
- Log . Debug ( "{0} waiting for an available session" , m_logArguments ) ;
40
+ Log . Debug ( "Pool {0} waiting for an available session" , m_logArguments ) ;
41
41
if ( ioBehavior == IOBehavior . Asynchronous )
42
42
await m_sessionSemaphore . WaitAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
43
43
else
@@ -57,12 +57,12 @@ public async ValueTask<ServerSession> GetSessionAsync(MySqlConnection connection
57
57
}
58
58
if ( session != null )
59
59
{
60
- Log . Debug ( "{0} found an existing session; checking it for validity" , m_logArguments ) ;
60
+ Log . Debug ( "Pool {0} found an existing session; checking it for validity" , m_logArguments ) ;
61
61
bool reuseSession ;
62
62
63
63
if ( session . PoolGeneration != m_generation )
64
64
{
65
- Log . Debug ( "{0} discarding session due to wrong generation" , m_logArguments ) ;
65
+ Log . Debug ( "Pool {0} discarding session due to wrong generation" , m_logArguments ) ;
66
66
reuseSession = false ;
67
67
}
68
68
else
@@ -84,7 +84,7 @@ public async ValueTask<ServerSession> GetSessionAsync(MySqlConnection connection
84
84
if ( ! reuseSession )
85
85
{
86
86
// session is either old or cannot communicate with the server
87
- Log . Warn ( "{0} Session{1} is unusable; destroying it" , m_logArguments [ 0 ] , session . Id ) ;
87
+ Log . Warn ( "Pool {0} Session{1} is unusable; destroying it" , m_logArguments [ 0 ] , session . Id ) ;
88
88
AdjustHostConnectionCount ( session , - 1 ) ;
89
89
await session . DisposeAsync ( ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
90
90
}
@@ -99,15 +99,15 @@ public async ValueTask<ServerSession> GetSessionAsync(MySqlConnection connection
99
99
leasedSessionsCountPooled = m_leasedSessions . Count ;
100
100
}
101
101
if ( Log . IsDebugEnabled ( ) )
102
- Log . Debug ( "{0} returning pooled Session{1} to caller; m_leasedSessions.Count ={2}" , m_logArguments [ 0 ] , session . Id , leasedSessionsCountPooled ) ;
102
+ Log . Debug ( "Pool {0} returning pooled Session{1} to caller; LeasedSessionsCount ={2}" , m_logArguments [ 0 ] , session . Id , leasedSessionsCountPooled ) ;
103
103
return session ;
104
104
}
105
105
}
106
106
107
107
// create a new session
108
108
session = new ServerSession ( this , m_generation , Interlocked . Increment ( ref m_lastSessionId ) ) ;
109
109
if ( Log . IsInfoEnabled ( ) )
110
- Log . Info ( "{0} no pooled session available; created new Session{1}" , m_logArguments [ 0 ] , session . Id ) ;
110
+ Log . Info ( "Pool {0} no pooled session available; created new Session{1}" , m_logArguments [ 0 ] , session . Id ) ;
111
111
await session . ConnectAsync ( ConnectionSettings , m_loadBalancer , ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
112
112
AdjustHostConnectionCount ( session , 1 ) ;
113
113
session . OwningConnection = new WeakReference < MySqlConnection > ( connection ) ;
@@ -118,7 +118,7 @@ public async ValueTask<ServerSession> GetSessionAsync(MySqlConnection connection
118
118
leasedSessionsCountNew = m_leasedSessions . Count ;
119
119
}
120
120
if ( Log . IsDebugEnabled ( ) )
121
- Log . Debug ( "{0} returning new Session{1} to caller; m_leasedSessions.Count ={2}" , m_logArguments [ 0 ] , session . Id , leasedSessionsCountNew ) ;
121
+ Log . Debug ( "Pool {0} returning new Session{1} to caller; LeasedSessionsCount ={2}" , m_logArguments [ 0 ] , session . Id , leasedSessionsCountNew ) ;
122
122
return session ;
123
123
}
124
124
catch
@@ -146,7 +146,7 @@ private bool SessionIsHealthy(ServerSession session)
146
146
public void Return ( ServerSession session )
147
147
{
148
148
if ( Log . IsDebugEnabled ( ) )
149
- Log . Debug ( "{0} receiving Session{1} back" , m_logArguments [ 0 ] , session . Id ) ;
149
+ Log . Debug ( "Pool {0} receiving Session{1} back" , m_logArguments [ 0 ] , session . Id ) ;
150
150
151
151
try
152
152
{
@@ -160,7 +160,7 @@ public void Return(ServerSession session)
160
160
}
161
161
else
162
162
{
163
- Log . Warn ( "{0} received invalid Session{1}; destroying it" , m_logArguments [ 0 ] , session . Id ) ;
163
+ Log . Warn ( "Pool {0} received invalid Session{1}; destroying it" , m_logArguments [ 0 ] , session . Id ) ;
164
164
AdjustHostConnectionCount ( session , - 1 ) ;
165
165
session . DisposeAsync ( IOBehavior . Synchronous , CancellationToken . None ) . GetAwaiter ( ) . GetResult ( ) ;
166
166
}
@@ -174,7 +174,7 @@ public void Return(ServerSession session)
174
174
public async Task ClearAsync ( IOBehavior ioBehavior , CancellationToken cancellationToken )
175
175
{
176
176
// increment the generation of the connection pool
177
- Log . Info ( "{0} clearing connection pool" , m_logArguments ) ;
177
+ Log . Info ( "Pool {0} clearing connection pool" , m_logArguments ) ;
178
178
Interlocked . Increment ( ref m_generation ) ;
179
179
m_procedureCache = null ;
180
180
RecoverLeakedSessions ( ) ;
@@ -183,7 +183,7 @@ public async Task ClearAsync(IOBehavior ioBehavior, CancellationToken cancellati
183
183
184
184
public async Task ReapAsync ( IOBehavior ioBehavior , CancellationToken cancellationToken )
185
185
{
186
- Log . Debug ( "{0} reaping connection pool" , m_logArguments ) ;
186
+ Log . Debug ( "Pool {0} reaping connection pool" , m_logArguments ) ;
187
187
RecoverLeakedSessions ( ) ;
188
188
await CleanPoolAsync ( ioBehavior , session => ( unchecked ( ( uint ) Environment . TickCount ) - session . LastReturnedTicks ) / 1000 >= ConnectionSettings . ConnectionIdleTimeout , true , cancellationToken ) . ConfigureAwait ( false ) ;
189
189
}
@@ -223,9 +223,9 @@ private void RecoverLeakedSessions()
223
223
}
224
224
}
225
225
if ( recoveredSessions . Count == 0 )
226
- Log . Debug ( "{0} recovered no sessions" , m_logArguments ) ;
226
+ Log . Debug ( "Pool {0} recovered no sessions" , m_logArguments ) ;
227
227
else
228
- Log . Warn ( "{0} recovered {1} sessions " , m_logArguments [ 0 ] , recoveredSessions . Count ) ;
228
+ Log . Warn ( "Pool {0}: RecoveredSessionCount= {1}" , m_logArguments [ 0 ] , recoveredSessions . Count ) ;
229
229
foreach ( var session in recoveredSessions )
230
230
session . ReturnToPool ( ) ;
231
231
}
@@ -279,7 +279,7 @@ private async Task CleanPoolAsync(IOBehavior ioBehavior, Func<ServerSession, boo
279
279
if ( shouldCleanFn ( session ) )
280
280
{
281
281
// session should be cleaned; dispose it and keep iterating
282
- Log . Info ( "{0} found Session{1} to clean up" , m_logArguments [ 0 ] , session . Id ) ;
282
+ Log . Info ( "Pool {0} found Session{1} to clean up" , m_logArguments [ 0 ] , session . Id ) ;
283
283
await session . DisposeAsync ( ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
284
284
}
285
285
else
@@ -329,7 +329,7 @@ private async Task CreateMinimumPooledSessions(IOBehavior ioBehavior, Cancellati
329
329
try
330
330
{
331
331
var session = new ServerSession ( this , m_generation , Interlocked . Increment ( ref m_lastSessionId ) ) ;
332
- Log . Info ( "{0} created Session{1} to reach minimum pool size" , m_logArguments [ 0 ] , session . Id ) ;
332
+ Log . Info ( "Pool {0} created Session{1} to reach minimum pool size" , m_logArguments [ 0 ] , session . Id ) ;
333
333
await session . ConnectAsync ( ConnectionSettings , m_loadBalancer , ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
334
334
AdjustHostConnectionCount ( session , 1 ) ;
335
335
lock ( m_sessions )
@@ -391,7 +391,7 @@ public static ConnectionPool GetPool(string connectionString)
391
391
}
392
392
else if ( pool != newPool && Log . IsInfoEnabled ( ) )
393
393
{
394
- Log . Info ( "{0} was created but will not be used (due to race)" , newPool . m_logArguments [ 0 ] ) ;
394
+ Log . Info ( "Pool {0} was created but will not be used (due to race)" , newPool . m_logArguments [ 0 ] ) ;
395
395
}
396
396
397
397
return pool ;
@@ -438,9 +438,9 @@ private ConnectionPool(ConnectionSettings cs)
438
438
( ILoadBalancer ) new RoundRobinLoadBalancer ( ) ;
439
439
440
440
Id = Interlocked . Increment ( ref s_poolId ) ;
441
- m_logArguments = new object [ ] { "Pool {0}" . FormatInvariant ( Id ) } ;
441
+ m_logArguments = new object [ ] { "{0}" . FormatInvariant ( Id ) } ;
442
442
if ( Log . IsInfoEnabled ( ) )
443
- Log . Info ( "{0} creating new connection pool for {1}" , m_logArguments [ 0 ] , cs . ConnectionStringBuilder . GetConnectionString ( includePassword : false ) ) ;
443
+ Log . Info ( "Pool {0} creating new connection pool for ConnectionString {1}" , m_logArguments [ 0 ] , cs . ConnectionStringBuilder . GetConnectionString ( includePassword : false ) ) ;
444
444
445
445
if ( cs . ConnectionIdleTimeout > 0 )
446
446
{
0 commit comments