Skip to content

Conversation

zbynek001
Copy link
Contributor

@zbynek001 zbynek001 commented Jul 15, 2018

contains

#3263

  • ClusterSingletonManager should ignore FSM events during shutdown

akka/akka#24048

  • Run all CoordinatedShutdown phases also when downing
  • add Reason to CoordinatedShutdown

akka/akka#24140

  • Allow member to leave a cluster via CoordinatedShutdown.run when MemberStatus is Joining/WeaklyUp/Up.

akka/akka#23449

  • ClusterSpec, race between MemberRemoved and MemberExited

@zbynek001 zbynek001 changed the title [WIP] Coordinated downing improvements Coordinated downing improvements Jul 15, 2018
@Horusiath
Copy link
Contributor

To be honest I think that #3284 may have covered this PR.

@zbynek001
Copy link
Contributor Author

It might, but I guess that's still far away.
Just wanted to share it when I already migrated it. But it's up to you whether you merge it or not. If not, will just add it to my custom build.

@Aaronontheweb Aaronontheweb self-requested a review July 15, 2018 23:10
Copy link
Member

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

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

Looks good to me.

}

/// <summary>
/// Using region 2 as it is not shutdown in either test.
Copy link
Member

Choose a reason for hiding this comment

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

Good to know (the comment was helpful during my review :p)

@@ -379,8 +379,15 @@ private void SetupCoordinatedShutdown()
var self = Self;
_coordShutdown.AddTask(CoordinatedShutdown.PhaseClusterShardingShutdownRegion, "region-shutdown", () =>
{
self.Tell(GracefulShutdown.Instance);
return _gracefulShutdownProgress.Task;
if (Cluster.IsTerminated || Cluster.SelfMember.Status == MemberStatus.Down)
Copy link
Member

Choose a reason for hiding this comment

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

Looks good

/// predefined reasons, but external libraries applications may also define
/// other reasons.
/// </summary>
public class Reason
Copy link
Member

Choose a reason for hiding this comment

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

I like this!

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually this should be an enum.

Copy link
Member

Choose a reason for hiding this comment

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

Disagree. If it needs properties and data that can be overridden in the future, for whatever reason, you can't have that extensibility with an Enum

Copy link
Member

Choose a reason for hiding this comment

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

I.E. the CustomReason example used in the spec earlier illustrates one such case for that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then you can easily change it into tagged union or just change from enum to class. It's time to stop putting enum-like types into singletons:

  1. They blow up the code base.
  2. They are hardly maintainable. You need a lot of boilerplate to keep things like equality, hash codes and string formatting in place.
  3. They are not safe - you never know if you have covered all switch cases and no tool on earth will help you with that.
  4. They are slow and memory-consuming (this don't matter much in this particular case).

If you can model some cases as enums, you should do that. This is not JVM, they won't be optimized automatically.

Copy link
Member

Choose a reason for hiding this comment

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

None of the above is true in this particular case - it's a class that gets used once on shutdown. I don't think these are even true generally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually started this as an enum, but then I got to the custom reason and I got stuck.
To support custom reasons with enum, we'd need to cast it to another enum extended with the custom reasons and I didn't like that. Honestly, the current approach I also don't like so much

@@ -1668,7 +1668,7 @@ public void Welcome(Address joinWith, UniqueAddress from, Gossip gossip)
public void Leaving(Address address)
{
// only try to update if the node is available (in the member ring)
if (_latestGossip.Members.Any(m => m.Address.Equals(address) && m.Status == MemberStatus.Up))
if (_latestGossip.Members.Any(m => m.Address.Equals(address) && (m.Status == MemberStatus.Joining || m.Status == MemberStatus.WeaklyUp || m.Status == MemberStatus.Up)))
Copy link
Member

Choose a reason for hiding this comment

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

Resolves #2347 while we're at it.

@Aaronontheweb Aaronontheweb merged commit dc8b77d into akkadotnet:dev Jul 31, 2018
@zbynek001 zbynek001 deleted the coordinated-downing branch July 16, 2021 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants