From 5acc5755465be7b84d407da165b6b43e3759cadf Mon Sep 17 00:00:00 2001 From: Roger Johansson Date: Thu, 21 Sep 2023 20:12:22 +0200 Subject: [PATCH 1/2] gossip error logger --- src/Proto.Cluster/Gossip/Gossiper.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Proto.Cluster/Gossip/Gossiper.cs b/src/Proto.Cluster/Gossip/Gossiper.cs index 096e53f5a6..44f34c6162 100644 --- a/src/Proto.Cluster/Gossip/Gossiper.cs +++ b/src/Proto.Cluster/Gossip/Gossiper.cs @@ -49,7 +49,9 @@ public class Gossiper { public const string GossipActorName = "$gossip"; +#pragma warning disable CS0618 // Type or member is obsolete private static readonly ILogger Logger = Log.CreateLogger(); +#pragma warning restore CS0618 // Type or member is obsolete private readonly Cluster _cluster; private readonly IRootContext _context; private PID _pid = null!; @@ -143,6 +145,7 @@ public void SetState(string key, IMessage value) if (_pid == null) { + Logger.LogError("Gossiper is not started, cannot set state"); return; } From c80ebc6e4a93af45e63e250bbe18e5aed9bd580f Mon Sep 17 00:00:00 2001 From: Roger Johansson Date: Thu, 21 Sep 2023 20:23:29 +0200 Subject: [PATCH 2/2] start gossip actor and gossip loop separately --- src/Proto.Cluster/Cluster.cs | 3 ++- src/Proto.Cluster/Gossip/Gossiper.cs | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Proto.Cluster/Cluster.cs b/src/Proto.Cluster/Cluster.cs index 2a5f7140e2..83cf7d952d 100644 --- a/src/Proto.Cluster/Cluster.cs +++ b/src/Proto.Cluster/Cluster.cs @@ -164,9 +164,10 @@ private void SubscribeToTopologyEvents() => /// public async Task StartMemberAsync() { + await Gossip.StartGossipActorAsync().ConfigureAwait(false); await BeginStartAsync(false).ConfigureAwait(false); //gossiper must be started whenever any topology events starts flowing - await Gossip.StartAsync().ConfigureAwait(false); + await Gossip.StartgossipLoopAsync().ConfigureAwait(false); MemberList.InitializeTopologyConsensus(); await Provider.StartMemberAsync(this).ConfigureAwait(false); Logger.LogInformation("Started as cluster member"); diff --git a/src/Proto.Cluster/Gossip/Gossiper.cs b/src/Proto.Cluster/Gossip/Gossiper.cs index 44f34c6162..77bbd1081f 100644 --- a/src/Proto.Cluster/Gossip/Gossiper.cs +++ b/src/Proto.Cluster/Gossip/Gossiper.cs @@ -181,7 +181,7 @@ public async Task SetStateAsync(string key, IMessage value) } } - internal Task StartAsync() + internal Task StartGossipActorAsync() { var props = Props.FromProducer(() => new GossipActor( _cluster.System, @@ -198,6 +198,13 @@ internal Task StartAsync() tmp.Left.Clear(); _context.Send(_pid, tmp); }); + + return Task.CompletedTask; + } + + internal Task StartgossipLoopAsync() + { + Logger.LogInformation("Started Cluster Gossip"); _ = SafeTask.Run(GossipLoop);