Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix client issue #2091

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/Proto.Cluster/DefaultClusterContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ public DefaultClusterContext(Cluster cluster)
public async Task<T?> RequestAsync<T>(ClusterIdentity clusterIdentity, object message, ISenderContext context,
CancellationToken ct)
{
if (!_cluster.JoinedCluster.IsCompletedSuccessfully)

//for member requests, we need to wait for the cluster to be ready
if (!_cluster.MemberList.IsClient)
{
await _cluster.JoinedCluster;
if (!_cluster.JoinedCluster.IsCompletedSuccessfully)
{
await _cluster.JoinedCluster;
}
}

var i = 0;

var future = context.GetFuture();
Expand Down
10 changes: 6 additions & 4 deletions src/Proto.Cluster/Member/MemberList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@ public record MemberList

private TaskCompletionSource<bool> _startedTcs = new(TaskCreationOptions.RunContinuationsAsynchronously);
private IConsensusHandle<ulong>? _topologyConsensus;
private readonly bool _asClient;
private readonly bool _isClient;

public MemberList(Cluster cluster, bool asClient = false)
public bool IsClient => _isClient;

public MemberList(Cluster cluster, bool isClient = false)
{
_cluster = cluster;
_system = _cluster.System;
_root = _system.Root;
_asClient = asClient;
_isClient = isClient;
var (host, port) = _cluster.System.GetAddress();

Self = new Member
Expand Down Expand Up @@ -239,7 +241,7 @@ public void UpdateClusterTopology(IReadOnlyCollection<Member> members)

if (!_startedTcs.Task.IsCompleted)
{
if (_asClient || activeMembers.Contains(_system.Id))
if (_isClient || activeMembers.Contains(_system.Id))
{
_startedTcs.TrySetResult(true);
}
Expand Down
Loading