diff --git a/src/Proto.Cluster/DefaultClusterContext.cs b/src/Proto.Cluster/DefaultClusterContext.cs index 4425cbbd8a..6e1967af5f 100644 --- a/src/Proto.Cluster/DefaultClusterContext.cs +++ b/src/Proto.Cluster/DefaultClusterContext.cs @@ -19,14 +19,17 @@ namespace Proto.Cluster; public class DefaultClusterContext : IClusterContext { +#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 IIdentityLookup _identityLookup; - private readonly PidCache _pidCache; private readonly ShouldThrottle _requestLogThrottle; private readonly ActorSystem _system; - private static readonly ILogger Logger = Log.CreateLogger(); private readonly int _requestTimeoutSeconds; private readonly bool _legacyTimeouts; + private readonly Cluster _cluster; public DefaultClusterContext(Cluster cluster) { @@ -34,6 +37,7 @@ public DefaultClusterContext(Cluster cluster) _pidCache = cluster.PidCache; var config = cluster.Config; _system = cluster.System; + _cluster = cluster; _requestLogThrottle = Throttle.Create( config.MaxNumberOfEventsInRequestLogThrottlePeriod, @@ -48,6 +52,11 @@ public DefaultClusterContext(Cluster cluster) public async Task RequestAsync(ClusterIdentity clusterIdentity, object message, ISenderContext context, CancellationToken ct) { + if (!_cluster.JoinedCluster.IsCompletedSuccessfully) + { + await _cluster.JoinedCluster; + } + var i = 0; var future = context.GetFuture(); diff --git a/src/Proto.Cluster/Gossip/Gossiper.cs b/src/Proto.Cluster/Gossip/Gossiper.cs index b04d784d9a..68a3040689 100644 --- a/src/Proto.Cluster/Gossip/Gossiper.cs +++ b/src/Proto.Cluster/Gossip/Gossiper.cs @@ -203,6 +203,8 @@ internal Task StartAsync() private async Task GossipLoop() { + Logger.LogInformation("Gossip is waiting for cluster to join"); + await _cluster.JoinedCluster; Logger.LogInformation("Starting gossip loop"); await Task.Yield();