Skip to content

Commit e93de40

Browse files
authored
Log multiplexer reconfiguration (#2864)
* Log Multiplexer reconfiguration * Include bridge name in connection exception
1 parent be5c8a6 commit e93de40

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

src/StackExchange.Redis/ConnectionMultiplexer.Sentinel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ internal void UpdateSentinelAddressList(string serviceName)
463463
if (hasNew)
464464
{
465465
// Reconfigure the sentinel multiplexer if we added new endpoints
466-
ReconfigureAsync(first: false, reconfigureAll: true, null, EndPoints[0], "Updating Sentinel List", false).Wait();
466+
ReconfigureAsync(first: false, reconfigureAll: true, Logger, EndPoints[0], "Updating Sentinel List", false).Wait();
467467
}
468468
}
469469
}

src/StackExchange.Redis/ConnectionMultiplexer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,7 @@ internal bool ReconfigureIfNeeded(EndPoint? blame, bool fromBroadcast, string ca
13781378
{
13791379
bool reconfigureAll = fromBroadcast || publishReconfigure;
13801380
Trace("Configuration change detected; checking nodes", "Configuration");
1381-
ReconfigureAsync(first: false, reconfigureAll, null, blame, cause, publishReconfigure, flags).ObserveErrors();
1381+
ReconfigureAsync(first: false, reconfigureAll, Logger, blame, cause, publishReconfigure, flags).ObserveErrors();
13821382
return true;
13831383
}
13841384
else
@@ -1393,7 +1393,7 @@ internal bool ReconfigureIfNeeded(EndPoint? blame, bool fromBroadcast, string ca
13931393
/// This re-assessment of all server endpoints to get the current topology and adjust, the same as if we had first connected.
13941394
/// </summary>
13951395
public Task<bool> ReconfigureAsync(string reason) =>
1396-
ReconfigureAsync(first: false, reconfigureAll: false, log: null, blame: null, cause: reason);
1396+
ReconfigureAsync(first: false, reconfigureAll: false, log: Logger, blame: null, cause: reason);
13971397

13981398
internal async Task<bool> ReconfigureAsync(bool first, bool reconfigureAll, ILogger? log, EndPoint? blame, string cause, bool publishReconfigure = false, CommandFlags publishReconfigureFlags = CommandFlags.None)
13991399
{

src/StackExchange.Redis/ExceptionFactory.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,14 @@ private static string GetLabel(bool includeDetail, RedisCommand command, Message
408408
return message == null ? command.ToString() : (includeDetail ? message.CommandAndKey : message.CommandString);
409409
}
410410

411-
internal static Exception UnableToConnect(ConnectionMultiplexer muxer, string? failureMessage = null)
411+
internal static Exception UnableToConnect(ConnectionMultiplexer muxer, string? failureMessage = null, string? connectionName = null)
412412
{
413-
var sb = new StringBuilder("It was not possible to connect to the redis server(s).");
413+
var sb = new StringBuilder("It was not possible to connect to the redis server(s)");
414+
if (connectionName is not null)
415+
{
416+
sb.Append(' ').Append(connectionName);
417+
}
418+
sb.Append('.');
414419
Exception? inner = null;
415420
var failureType = ConnectionFailureType.UnableToConnect;
416421
if (muxer is not null)

src/StackExchange.Redis/PhysicalBridge.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ internal void OnHeartbeat(bool ifConnectedOnly)
584584
if (DueForConnectRetry())
585585
{
586586
Interlocked.Increment(ref connectTimeoutRetryCount);
587-
var ex = ExceptionFactory.UnableToConnect(Multiplexer, "ConnectTimeout");
587+
var ex = ExceptionFactory.UnableToConnect(Multiplexer, "ConnectTimeout", Name);
588588
LastException = ex;
589589
Multiplexer.Logger?.LogError(ex, ex.Message);
590590
Trace("Aborting connect");

0 commit comments

Comments
 (0)