From 188fc0bec7f25de8baa4887166eccf7ec43d7303 Mon Sep 17 00:00:00 2001 From: Ismael Hamed <1279846+ismaelhamed@users.noreply.github.com> Date: Tue, 11 May 2021 14:51:35 +0200 Subject: [PATCH] Reduce sharding warnings when there are no buffered messages (#5003) Co-authored-by: Aaron Stannard --- .../Akka.Cluster.Sharding/ShardRegion.cs | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/ShardRegion.cs b/src/contrib/cluster/Akka.Cluster.Sharding/ShardRegion.cs index efda79c5404..784271accba 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/ShardRegion.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/ShardRegion.cs @@ -664,11 +664,25 @@ private void Register() ? $"Coordinator [{MembersByAge.First()}] is unreachable." : $"Coordinator [{MembersByAge.First()}] is reachable."; - Log.Warning("{0}: Trying to register to coordinator at [{1}], but no acknowledgement. Total [{2}] buffered messages. [{3}]", - TypeName, - string.Join(", ", actorSelections.Select(i => i.PathString)), - TotalBufferSize, - coordinatorMessage); + var bufferSize = ShardBuffers.Count; + if (bufferSize > 0) + { + if (Log.IsWarningEnabled) + { + Log.Warning("{0}: Trying to register to coordinator at [{1}], but no acknowledgement. Total [{2}] buffered messages. [{3}]", + TypeName, + string.Join(", ", actorSelections.Select(i => i.PathString)), + TotalBufferSize, + coordinatorMessage); + } + } + else if (Log.IsDebugEnabled) + { + Log.Debug("{0}: Trying to register to coordinator at [{1}], but no acknowledgement. No buffered messages yet. [{2}]", + TypeName, + string.Join(", ", actorSelections.Select(i => i.PathString)), + coordinatorMessage); + } } else { @@ -678,8 +692,17 @@ private void Register() ? "Has Cluster Sharding been started on every node and nodes been configured with the correct role(s)?" : "Probably, no seed-nodes configured and manual cluster join not performed?"; - Log.Warning("{0}: No coordinator found to register. {1} Total [{2}] buffered messages.", - TypeName, possibleReason, TotalBufferSize); + var bufferSize = ShardBuffers.Count; + if (bufferSize > 0) + { + Log.Warning("{0}: No coordinator found to register. {1} Total [{2}] buffered messages.", + TypeName, possibleReason, TotalBufferSize); + } + else + { + Log.Debug("{0}: No coordinator found to register. {1} No buffered messages yet.", + TypeName, possibleReason); + } } } }