Skip to content

Commit

Permalink
close akkadotnet#3274 - fixed weaklyup nodes stuck at joining
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb committed Jan 17, 2018
1 parent d83973b commit f39c439
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
28 changes: 28 additions & 0 deletions src/core/Akka.Cluster.Tests/MemberOrderingSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public void MemberOrdering_must_work_pick_member_with_legal_transition()
var address1 = new Address("akka.tcp", "sys1", "host1", 9001);
var address2 = address1.WithPort(9002);
var address3 = address1.WithPort(9003);
var address4 = address1.WithPort(9004);

var s1 = ImmutableSortedSet
.Create(TestMember.Create(address1, MemberStatus.Joining))
Expand Down Expand Up @@ -127,6 +128,33 @@ public void MemberOrdering_must_work_pick_member_with_legal_transition()
var u2 = Member.PickNextTransition(s4, s1);
u2.Should().BeEquivalentTo(s5);
u2.Single(x => x.Address.Equals(address1)).Status.Should().Be(MemberStatus.Up);

// WeaklyUp assertions
var s6 = ImmutableSortedSet
.Create(TestMember.Create(address1, MemberStatus.Up))
.Add(TestMember.Create(address2, MemberStatus.Up))
.Add(TestMember.Create(address3, MemberStatus.Up))
.Add(TestMember.Create(address4, MemberStatus.Joining));

var s7 = ImmutableSortedSet
.Create(TestMember.Create(address1, MemberStatus.Up))
.Add(TestMember.Create(address2, MemberStatus.Up))
.Add(TestMember.Create(address3, MemberStatus.Up))
.Add(TestMember.Create(address4, MemberStatus.WeaklyUp));

var u3 = Member.PickNextTransition(s6, s7);
u3.Should().BeEquivalentTo(s7);
u3.Single(x => x.Address.Equals(address4)).Status.Should().Be(MemberStatus.WeaklyUp);

var s8 = ImmutableSortedSet
.Create(TestMember.Create(address1, MemberStatus.Up))
.Add(TestMember.Create(address2, MemberStatus.Up))
.Add(TestMember.Create(address3, MemberStatus.Up))
.Add(TestMember.Create(address4, MemberStatus.Up));

var u4 = Member.PickNextTransition(s8, s7);
u4.Should().BeEquivalentTo(s8);
u4.Single(x => x.Address.Equals(address4)).Status.Should().Be(MemberStatus.Up);
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Cluster/ClusterDaemon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2160,7 +2160,7 @@ bool IsJoiningToWeaklyUp(Member m) => m.Status == MemberStatus.Joining
if (!changedMembers.IsEmpty)
{
// replace changed members
var newMembers = changedMembers.Union(localMembers);
var newMembers = Member.PickNextTransition(localMembers, changedMembers);
var newGossip = localGossip.Copy(members: newMembers);
UpdateLatestGossip(newGossip);

Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Cluster/Member.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ public static Member HighestPriorityOf(Member m1, Member m2)
/// <summary>
/// Defines the current status of a cluster member node
///
/// Can be one of: Joining, Up, Leaving, Exiting and Down.
/// Can be one of: Joining, Up, WeaklyUp, Leaving, Exiting and Down.
/// </summary>
public enum MemberStatus
{
Expand Down

0 comments on commit f39c439

Please sign in to comment.