fix(cluster): enable SBR downing provider — automatic failover was inert for crashes/partitions

This commit is contained in:
Joseph Doherty
2026-07-08 14:48:18 -04:00
parent c2230b7171
commit c3a9e708a2
2 changed files with 24 additions and 0 deletions
@@ -201,6 +201,11 @@ public class AkkaHostedService : IHostedService
/// <see cref="ClusterOptions.DownIfAlone"/> rather than hard-coded, so the bound
/// configuration value is actually consumed.
///
/// The split-brain-resolver <c>downing-provider-class</c> is installed
/// explicitly: Akka defaults to <c>NoDowning</c>, under which the entire
/// split-brain-resolver section is inert and singletons never migrate on a hard
/// crash or partition. Naming the SBR provider is what activates automatic downing.
///
/// Every duration is rendered via <see cref="DurationHocon"/> in
/// milliseconds, so sub-second cluster timing values (e.g. a 750ms heartbeat) are
/// preserved exactly instead of being rounded to whole seconds.
@@ -251,6 +256,7 @@ akka {{
seed-nodes = [{seedNodesStr}]
roles = [{rolesStr}]
min-nr-of-members = {clusterOptions.MinNrOfMembers}
downing-provider-class = ""Akka.Cluster.SBR.SplitBrainResolverProvider, Akka.Cluster""
split-brain-resolver {{
active-strategy = {QuoteHocon(clusterOptions.SplitBrainResolverStrategy)}
stable-after = {DurationHocon(clusterOptions.StableAfter)}
@@ -160,4 +160,22 @@ public class HoconBuilderTests
TimeSpan.FromMilliseconds(7500),
config.GetTimeSpan("akka.remote.transport-failure-detector.acceptable-heartbeat-pause"));
}
[Fact]
public void BuildHocon_EnablesSplitBrainResolverDowningProvider()
{
// Review 01 [Critical]: without downing-provider-class the entire
// split-brain-resolver section is inert (Akka default = NoDowning) and
// singletons never migrate on a hard crash.
var node = new NodeOptions { Role = "Central", NodeHostname = "node1", RemotingPort = 8081 };
var hocon = AkkaHostedService.BuildHocon(
node, DefaultCluster(), new[] { "Central" },
TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(15));
var config = ConfigurationFactory.ParseString(hocon);
Assert.Equal(
"Akka.Cluster.SBR.SplitBrainResolverProvider, Akka.Cluster",
config.GetString("akka.cluster.downing-provider-class"));
}
}