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

bug fix: timing regressions in Cluster.JoinAsync methods #6471

Merged
merged 5 commits into from
Feb 28, 2023
Merged
Changes from 1 commit
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
Next Next commit
fix timing regressions in Cluster.JoinAsync methods
We used the `cluster.seed-node-timeout` property incorrectly in #6033 - that is a "how long did it take from me to hear back from a seed" setting, but we're using it like a "how much time do I have to join the cluster?" setting.

Added a function designed to give us at least 20s of leeway.
Aaronontheweb committed Feb 28, 2023
commit 323883fa3a0e6077993edb64da6b539d6e1a4b7a
14 changes: 12 additions & 2 deletions src/core/Akka.Cluster/Cluster.cs
Original file line number Diff line number Diff line change
@@ -243,6 +243,16 @@ public void Join(Address address)
ClusterCore.Tell(new ClusterUserAction.JoinTo(FillLocal(address)));
}

/// <summary>
/// Want at least 10-20 seconds of leeway here.
/// </summary>
private TimeSpan ComputeJoinTimeLimit()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5s, the currently used value, is unrealistically short - 10s-20s is more appropriate.

{
return TimeSpan.FromSeconds(Math.Max(
(Settings.RetryUnsuccessfulJoinAfter ?? TimeSpan.FromSeconds(10)).TotalSeconds,
TimeSpan.FromSeconds(20).TotalSeconds));
}

/// <summary>
/// Try to asynchronously join this cluster node specified by <paramref name="address"/>.
/// A <see cref="Join"/> command is sent to the node to join. Returned task will be completed
@@ -273,7 +283,7 @@ public Task JoinAsync(Address address, CancellationToken token = default)
var completion = new TaskCompletionSource<NotUsed>(TaskCreationOptions.RunContinuationsAsynchronously);

var timeoutCts = CancellationTokenSource.CreateLinkedTokenSource(token);
timeoutCts.CancelAfter(Settings.SeedNodeTimeout);
timeoutCts.CancelAfter(ComputeJoinTimeLimit());
timeoutCts.Token.Register(() =>
{
timeoutCts.Dispose();
@@ -350,7 +360,7 @@ public Task JoinSeedNodesAsync(IEnumerable<Address> seedNodes, CancellationToken
var nodes = seedNodes.ToList();

var timeoutCts = CancellationTokenSource.CreateLinkedTokenSource(token);
timeoutCts.CancelAfter(Settings.SeedNodeTimeout);
timeoutCts.CancelAfter(ComputeJoinTimeLimit());
timeoutCts.Token.Register(() =>
{
timeoutCts.Dispose();