Skip to content

Commit df0047f

Browse files
Filter out 'temporary placeholder' clsuter nodes with handshake flag that redis creates internally during cluster handshake (during initial cluster MEET, cluster MEET, cluster PONG sequence) since they are not expected to be usable members of the cluster at that time.
1 parent 600119e commit df0047f

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/StackExchange.Redis/ClusterConfiguration.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ internal ClusterConfiguration(ServerSelectionStrategy serverSelectionStrategy, s
181181
if (node.IsNoAddr || node.IsFail || node.EndPoint == null)
182182
continue;
183183

184+
// Be resilient to "handshake" nodes, which are nodes that are in the process of joining the cluster and hence might not have all information available yet.
185+
// These nodes will be included in the configuration once they finish the handshake process and are fully part of the cluster, so we can safely ignore them for now.
186+
if (node.IsHandshake)
187+
continue;
188+
184189
// Override the origin value with the endpoint advertised with the target node to
185190
// make sure that things like clusterConfiguration[clusterConfiguration.Origin]
186191
// will work as expected.
@@ -308,6 +313,7 @@ internal ClusterNode(ClusterConfiguration configuration, string raw, EndPoint or
308313
}
309314

310315
NodeId = parts[0];
316+
IsHandshake = flags.Contains("handshake");
311317
IsFail = flags.Contains("fail");
312318
IsPossiblyFail = flags.Contains("fail?");
313319
IsReplica = flags.Contains("slave") || flags.Contains("replica");
@@ -377,6 +383,14 @@ public IList<ClusterNode> Children
377383
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
378384
public bool IsSlave => IsReplica;
379385

386+
/// <summary>
387+
/// The handshake flag is set for nodes which are currently in the process of joining the cluster.
388+
/// They might not be fully configured, node IDs and slot ranges are placeholder information, and endpoint details 'best guess'.
389+
/// We use this property only to filter out handshake nodes when building the configuration,
390+
/// since they may be unusable, so it is not made public for now.
391+
/// </summary>
392+
internal bool IsHandshake { get; }
393+
380394
/// <summary>
381395
/// Gets whether this node is a replica.
382396
/// </summary>

0 commit comments

Comments
 (0)