From b1db6b669a5391cf09bd3a283b01e25885e04db8 Mon Sep 17 00:00:00 2001 From: Roger Johansson Date: Sat, 23 Aug 2025 19:16:11 +0200 Subject: [PATCH] fix: initialize gossip after cluster services --- logs/log1755969060.md | 8 ++++++++ src/Proto.Cluster/Cluster.cs | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 logs/log1755969060.md diff --git a/logs/log1755969060.md b/logs/log1755969060.md new file mode 100644 index 0000000000..5f4fc76de6 --- /dev/null +++ b/logs/log1755969060.md @@ -0,0 +1,8 @@ +# Log 1755969060 + +## Summary +- Reordered `StartMemberAsync` to call `BeginStartAsync` before `StartGossipActorAsync`, ensuring `MemberList` and `Remote` are initialized before gossip starts. +- Added a clarifying comment documenting the dependency. + +## Motivation +`StartGossipActorAsync` accessed `MemberList` and the remote block list before they were initialized, leading to intermittent null-reference failures during cluster startup and tests. diff --git a/src/Proto.Cluster/Cluster.cs b/src/Proto.Cluster/Cluster.cs index c1984b5525..2578a922ff 100644 --- a/src/Proto.Cluster/Cluster.cs +++ b/src/Proto.Cluster/Cluster.cs @@ -164,9 +164,9 @@ private void SubscribeToTopologyEvents() => /// public async Task StartMemberAsync() { + await BeginStartAsync(false).ConfigureAwait(false); // ensure MemberList and Remote are initialized await Gossip.StartGossipActorAsync().ConfigureAwait(false); - await BeginStartAsync(false).ConfigureAwait(false); - //gossiper must be started whenever any topology events starts flowing + // gossiper must be started whenever any topology events starts flowing await Gossip.StartgossipLoopAsync().ConfigureAwait(false); MemberList.InitializeTopologyConsensus(); await Provider.StartMemberAsync(this).ConfigureAwait(false);