Skip to content

Commit

Permalink
cluster coordinated leave fix for empty cluster (#3516)
Browse files Browse the repository at this point in the history
  • Loading branch information
zbynek001 authored and Aaronontheweb committed Jun 19, 2018
1 parent 762c2b8 commit 98a740f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/core/Akka.Cluster/ClusterDaemon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,13 @@ private void AddCoordinatedLeave()
{
var sys = Context.System;
var self = Self;
_coordShutdown.AddTask(CoordinatedShutdown.PhaseClusterExiting, "wait-exiting", () => _selfExiting.Task);
_coordShutdown.AddTask(CoordinatedShutdown.PhaseClusterExiting, "wait-exiting", () =>
{
if (_latestGossip.Members.IsEmpty)
return Task.FromResult(Done.Instance); // not joined yet
else
return _selfExiting.Task;
});
_coordShutdown.AddTask(CoordinatedShutdown.PhaseClusterExitingDone, "exiting-completed", () =>
{
if (Cluster.Get(sys).IsTerminated)
Expand Down
10 changes: 8 additions & 2 deletions src/core/Akka.Cluster/CoordinatedShutdownLeave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Akka.Cluster
{
/// <summary>
/// INTERNAL API
///
///
/// Used for executing <see cref="CoordinatedShutdown"/> phases for graceful
/// <see cref="Cluster.Leave"/> behaviors.
/// </summary>
Expand Down Expand Up @@ -55,7 +55,13 @@ private void WaitingLeaveCompleted(IActorRef replyTo)
{
Receive<ClusterEvent.CurrentClusterState>(s =>
{
if (s.Members.Any(m => m.UniqueAddress.Equals(_cluster.SelfUniqueAddress)
if (s.Members.IsEmpty)
{
// not joined yet
replyTo.Tell(Done.Instance);
Context.Stop(Self);
}
else if (s.Members.Any(m => m.UniqueAddress.Equals(_cluster.SelfUniqueAddress)
&&
(m.Status == MemberStatus.Leaving || m.Status == MemberStatus.Exiting ||
m.Status == MemberStatus.Down)))
Expand Down

0 comments on commit 98a740f

Please sign in to comment.