-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Akka.Cluster: enable keep-majority
default SBR
#6628
Changes from 18 commits
9215e9b
fb42fda
e9b08c2
3782132
7ca8104
6e74d88
97eb1c2
24d46b9
248404f
9df4d23
ed9918c
b6a4ab5
3df700b
2563099
5ab3acc
658ab28
6ee93e5
5337e46
251fade
1705fc7
7eedcdd
e45d60f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,19 @@ Keep in mind that split brain resolver will NOT work when `akka.cluster.auto-dow | |
|
||
Beginning in Akka.NET v1.4.16, the Akka.NET project has ported the original split brain resolver implementations from Lightbend as they are now open source. The following section of documentation describes how Akka.NET's hand-rolled split brain resolvers are implemented. | ||
|
||
> [!IMPORTANT] | ||
> As of Akka.NET v1.5.2, the `keep-majority` split brain resolution strategy is now enabled by default. This should be acceptable for the majority of Akka.Cluster users, but please read on. | ||
|
||
### Disabling the Default Downing Provider | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add section explaining how to disable default downing provider. |
||
|
||
To disable the default Akka.Cluster downing provider, simply configure the following in your HOCON: | ||
|
||
```hocon | ||
akka.cluster.downing-provider-class = "" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question, since we removed AutoDowning, what will happen if a user turn SBR off? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Answered in chat - nothing. AutoDowning was never enabled by default and we strongly discouraged users from ever enabling it. If the default SBR is disabled Akka.Cluster behaves exactly like it does today: unreachable nodes stay unreachable until downed manually by |
||
``` | ||
|
||
This will disable the split brain resolver / downing provider functionality altogether in Akka.NET. This was the default behavior for Akka.Cluster as of Akka.NET v1.5.1 and earlier. | ||
|
||
### Picking a Strategy | ||
|
||
In order to enable an Akka.NET split brain resolver in your cluster (they are not enabled by default), you will want to update your `akka.cluster` HOCON configuration to the following: | ||
|
@@ -59,7 +72,7 @@ This will cause the [`Akka.Cluster.SBR.SplitBrainResolverProvider`](xref:Akka.Cl | |
The following strategies are supported: | ||
|
||
* `static-quorum` | ||
* `keep-majority` | ||
* `keep-majority` **(default)** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, tried to make it clear what the defaults are here. |
||
* `keep-oldest` | ||
* `down-all` | ||
* `lease-majority` | ||
|
@@ -144,6 +157,9 @@ akka.cluster.split-brain-resolver { | |
|
||
#### Keep Majority | ||
|
||
> [!NOTE] | ||
> `keep-majority` is the default SBR strategy for Akka.Cluster as of Akka.NET v1.5.2+. | ||
|
||
The `keep-majority` strategy will down this part of the cluster, which sees a lesser part of the whole cluster. This choice is made based on the latest known state of the cluster. When cluster will split into two equal parts, the one which contains the lowest address, will survive. | ||
|
||
When to use it? When your cluster can grow or shrink very dynamically. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,48 @@ This document contains specific upgrade suggestions, warnings, and notices that | |
<iframe width="560" height="315" src="https://www.youtube.com/embed/-UPestlIw4k" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe> | ||
<!-- markdownlint-enable MD033 --> | ||
|
||
## Upgrading to Akka.NET v1.5.2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Upgrade advisories for this PR as well as #6389 |
||
|
||
Akka.NET v1.5.2 introduces two important behavioral changes: | ||
|
||
* [Akka.Persistence: need to remove hard-coded Newtonsoft.Json `object` serializer](https://github.com/akkadotnet/akka.net/issues/6389) | ||
* [Akka.Cluster: enable `keep-majority` as default Split Brain Resolver](https://github.com/akkadotnet/akka.net/pull/6628) | ||
|
||
We meant to include both of these changes in Akka.NET v1.5.0 but simply ran out of time before making them into that release. | ||
|
||
### Akka.Persistence Changes | ||
|
||
The impact of [Akka.Persistence: need to remove hard-coded Newtonsoft.Json `object` serializer](https://github.com/akkadotnet/akka.net/issues/6389) is pretty minor: all versions of Akka.NET prior to 1.5.2 used Newtonsoft.Json as the `object` serializer for Akka.Persistence regardless of whether or not you [used a custom `object` serializer, such as Hyperion](xref:serialization#complex-object-serialization-using-hyperion). | ||
|
||
Going forward your user-defined `object` serialization binding will now be respected by Akka.Persistence. Any old data previously saved using Newtonsoft.Json will continue to be recovered automatically by Newtonsoft.Json - it's only the serialization of new objects inserted after upgrading to v1.5.2 that will be affected. | ||
|
||
If you _never changed your `object`_ serializer (most users don't) then this change doesn't affect you. | ||
|
||
### Akka.Cluster Split Brain Resolver Changes | ||
|
||
As of Akka.NET v1.5.2 we've now enabled the `keep-majority` [Split Brain Resolver](xref:split-brain-resolver) by default. | ||
|
||
If you were already running with a custom SBR enabled, this change won't affect you. | ||
|
||
If you weren't running with an SBR enabled, you should read the [Akka.Cluster Split Brain Resolver documentation](xref:split-brain-resolver). | ||
|
||
Also worth noting: we've disabled the `akka.cluster.auto-down-unreachable-after` setting as it's always been a poor and shoddy way to manage network partitions inside Akka.Cluster. If you have that setting enabled it will be ignored and you'll see the following warning appear instead: | ||
|
||
```shell | ||
The `auto-down-unreachable-after` feature has been deprecated as of Akka.NET v1.5.2 and will be removed in a future version of Akka.NET. | ||
The `keep-majority` split brain resolver will be used instead. See https://getakka.net/articles/cluster/split-brain-resolver.html for more details. | ||
``` | ||
|
||
#### Disabling the Default Downing Provider | ||
|
||
To disable the default Akka.Cluster downing provider, simply configure the following in your HOCON: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicated this section from the Split Brain Resolver page - explains how to disable the new default SBR, since I'm fairly certain we'll get a question about that in the future. |
||
|
||
```hocon | ||
akka.cluster.downing-provider-class = "" | ||
``` | ||
|
||
This will disable the split brain resolver / downing provider functionality altogether in Akka.NET. This was the default behavior for Akka.Cluster as of Akka.NET v1.5.1 and earlier. | ||
|
||
## Upgrading From Akka.NET v1.4 to v1.5 | ||
|
||
In case you need help upgrading: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,9 @@ public ClusterShardingSpecConfig( | |
CommonConfig = ConfigurationFactory.ParseString($@" | ||
akka.cluster.sharding.verbose-debug-logging = on | ||
#akka.loggers = [""akka.testkit.SilenceAllTestEventListener""] | ||
|
||
akka.cluster.downing-provider-class = ""Akka.Cluster.SBR.SplitBrainResolverProvider, Akka.Cluster"" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This spec previously relied on
|
||
akka.cluster.split-brain-resolver.stable-after = 1s | ||
akka.cluster.down-removal-margin = 1s | ||
akka.cluster.roles = [""backend""] | ||
akka.cluster.distributed-data.gossip-interval = 1s | ||
akka.persistence.journal.sqlite-shared.timeout = 10s #the original default, base test uses 5s | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ public void ClusterSingletonManagerSettings_must_have_default_config() | |
clusterSingletonManagerSettings.SingletonName.ShouldBe("singleton"); | ||
clusterSingletonManagerSettings.Role.ShouldBe(null); | ||
clusterSingletonManagerSettings.HandOverRetryInterval.TotalSeconds.ShouldBe(1); | ||
clusterSingletonManagerSettings.RemovalMargin.TotalSeconds.ShouldBe(0); | ||
clusterSingletonManagerSettings.RemovalMargin.TotalSeconds.ShouldBe(20); // now 20 due to default SBR settings | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
var config = Sys.Settings.Config.GetConfig("akka.cluster.singleton"); | ||
Assert.False(config.IsNullOrEmpty()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
[assembly: System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName=".NET 6.0")] | ||
namespace Akka.Cluster | ||
{ | ||
[System.ObsoleteAttribute("No longer used as of Akka.NET v1.5.2")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
public sealed class AutoDowning : Akka.Cluster.IDowningProvider | ||
{ | ||
public AutoDowning(Akka.Actor.ActorSystem system, Akka.Cluster.Cluster cluster) { } | ||
|
@@ -192,6 +193,8 @@ namespace Akka.Cluster | |
public ClusterSettings(Akka.Configuration.Config config, string systemName) { } | ||
public bool AllowWeaklyUpMembers { get; } | ||
public Akka.Util.AppVersion AppVersion { get; } | ||
[System.ObsoleteAttribute("No longer used as of Akka.NET v1.5.2 - clustering defaults to using KeepMajority " + | ||
"SBR instead")] | ||
public System.Nullable<System.TimeSpan> AutoDownUnreachableAfter { get; } | ||
public System.Type DowningProviderType { get; } | ||
public Akka.Configuration.Config FailureDetectorConfig { get; } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
using System; | ||
using System.Collections.Immutable; | ||
using Akka.Actor; | ||
using Akka.Cluster.SBR; | ||
using Akka.Configuration; | ||
using Akka.Dispatch; | ||
using Akka.Remote; | ||
|
@@ -44,7 +45,9 @@ public void Clustering_must_be_able_to_parse_generic_cluster_config_elements() | |
settings.AllowWeaklyUpMembers.Should().BeTrue(); | ||
settings.WeaklyUpAfter.Should().Be(7.Seconds()); | ||
settings.PublishStatsInterval.Should().NotHaveValue(); | ||
#pragma warning disable CS0618 | ||
settings.AutoDownUnreachableAfter.Should().NotHaveValue(); | ||
#pragma warning restore CS0618 | ||
settings.DownRemovalMargin.Should().Be(TimeSpan.Zero); | ||
settings.MinNrOfMembers.Should().Be(1); | ||
settings.MinNrOfMembersOfRole.Should().Equal(ImmutableDictionary<string, int>.Empty); | ||
|
@@ -71,6 +74,13 @@ public void Clustering_must_be_able_to_parse_generic_cluster_config_elements() | |
settings.VerboseHeartbeatLogging.Should().BeFalse(); | ||
settings.VerboseGossipReceivedLogging.Should().BeFalse(); | ||
settings.RunCoordinatedShutdownWhenDown.Should().BeTrue(); | ||
|
||
// downing provider settings | ||
settings.DowningProviderType.Should().Be<SplitBrainResolverProvider>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assert the new default SBR settings. |
||
var sbrSettings = new SplitBrainResolverSettings(Sys.Settings.Config); | ||
sbrSettings.DowningStableAfter.Should().Be(20.Seconds()); | ||
sbrSettings.DownAllWhenUnstable.Should().Be(15.Seconds()); // 3/4 OF DowningStableAfter | ||
sbrSettings.DowningStrategy.Should().Be("keep-majority"); | ||
} | ||
|
||
/// <summary> | ||
|
@@ -83,5 +93,17 @@ public void Clustering_should_parse_nondefault_AppVersion() | |
var settings = new ClusterSettings(config.WithFallback(Sys.Settings.Config), Sys.Name); | ||
settings.AppVersion.Should().Be(AppVersion.Zero); | ||
} | ||
|
||
/// <summary> | ||
/// Validate that we can disable the default downing provider if needed | ||
/// </summary> | ||
[Fact] | ||
public void Cluster_should_allow_disabling_of_default_DowningProvider() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validate that the new defaults can be disabled / overridden. |
||
{ | ||
// configure HOCON to disable the default akka.cluster downing provider | ||
Config config = "akka.cluster.downing-provider-class = \"\""; | ||
var settings = new ClusterSettings(config.WithFallback(Sys.Settings.Config), Sys.Name); | ||
settings.DowningProviderType.Should().Be<NoDowning>(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,13 +67,11 @@ static Cluster() | |
bool GetAssertInvariants() | ||
{ | ||
var isOn = Environment.GetEnvironmentVariable("AKKA_CLUSTER_ASSERT")?.ToLowerInvariant(); | ||
switch (isOn) | ||
return isOn switch | ||
{ | ||
case "on": | ||
return true; | ||
default: | ||
return false; | ||
} | ||
"on" => true, | ||
_ => false | ||
}; | ||
} | ||
|
||
IsAssertInvariantsEnabled = GetAssertInvariants(); | ||
|
@@ -114,12 +112,24 @@ public Cluster(ActorSystemImpl system) | |
System = system; | ||
Settings = new ClusterSettings(system.Settings.Config, system.Name); | ||
|
||
if (!(system.Provider is IClusterActorRefProvider provider)) | ||
if (system.Provider is not IClusterActorRefProvider provider) | ||
throw new ConfigurationException( | ||
$"ActorSystem {system} needs to have a 'IClusterActorRefProvider' enabled in the configuration, currently uses {system.Provider.GetType().FullName}"); | ||
SelfUniqueAddress = new UniqueAddress(provider.Transport.DefaultAddress, AddressUidExtension.Uid(system)); | ||
|
||
_log = Logging.GetLogger(system, "Cluster"); | ||
|
||
// log a warning if the user has set auto-down-unreachable-after to any value other than "off" | ||
// obsolete setting, so suppress obsolete warning | ||
#pragma warning disable CS0618 | ||
if (Settings.AutoDownUnreachableAfter != null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a user still has |
||
#pragma warning restore CS0618 | ||
{ | ||
_log.Warning( | ||
"The `auto-down-unreachable-after` feature has been deprecated as of Akka.NET v1.5.2 and will be removed in a future version of Akka.NET. " + | ||
"The `keep-majority` split brain resolver will be used instead. See https://getakka.net/articles/cluster/split-brain-resolver.html for more details."); | ||
} | ||
|
||
|
||
CurrentInfoLogger = new InfoLogger(_log, Settings, SelfAddress); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried to make it clear that there is now a default SBR enabled.