Skip to content
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.Sharding: enable prefer-oldest by default on Replicator #7290

Merged
merged 5 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,21 @@ public void Should_cluster_sharding_settings_have_default_config()
clusterShardingSettings.TuningParameters.CoordinatorStateReadMajorityPlus.Should().Be(5);
clusterShardingSettings.TuningParameters.CoordinatorStateWriteMajorityPlus.Should().Be(3);
}

[Fact]
public void ClusterSharding_replicator_settings_should_have_default_values()
{
ClusterSharding.Get(Sys);
var clusterShardingSettings = ClusterShardingSettings.Create(Sys);
var replicatorSettings = ClusterShardingGuardian.GetReplicatorSettings(clusterShardingSettings);

replicatorSettings.Should().NotBeNull();
replicatorSettings.Role.Should().BeNullOrEmpty();

// only populated when remember-entities is enabled
replicatorSettings.DurableKeys.Should().BeEmpty();
replicatorSettings.MaxDeltaElements.Should().Be(5);
replicatorSettings.PreferOldest.Should().BeTrue();
Copy link
Member Author

Choose a reason for hiding this comment

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

Detect whether or not PreferOldest is enabled.

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public ClusterShardingGuardian(
});
}

private ReplicatorSettings GetReplicatorSettings(ClusterShardingSettings shardingSettings)
internal static ReplicatorSettings GetReplicatorSettings(ClusterShardingSettings shardingSettings)
Copy link
Member Author

Choose a reason for hiding this comment

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

Made this internal in order to make it easy to test the real ReplicatorSettings that we're passing into DData - straight from the source.

{
var config = Context.System.Settings.Config.GetConfig("akka.cluster.sharding.distributed-data")
.WithFallback(Context.System.Settings.Config.GetConfig("akka.cluster.distributed-data"));
Expand Down
3 changes: 3 additions & 0 deletions src/contrib/cluster/Akka.Cluster.Sharding/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ akka.cluster.sharding {
distributed-data {
# minCap parameter to MajorityWrite and MajorityRead consistency level.
majority-min-cap = 5

# ShardCoordinator is singleton running on oldest
prefer-oldest = on
Copy link
Member Author

Choose a reason for hiding this comment

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

prefer-oldest should have been enabled for the DDataShardCoordinator when #5146 was originally introduced, but I overlooked it. This should play a key factor in #6973 - where LWWRegister data from the DDataShardCoordinator is going missing when the coordinator is pushing updates as it's exiting the cluster.


durable.keys = ["shard-*"]

Expand Down