microsoft/garnet · error · Exception
Gossip sample fraction should be in range [0,100]
Error message
Gossip sample fraction should be in range [0,100]
What it means
ClusterProvider's constructor validates that serverOptions.GossipSamplePercent is within [0,100] and throws a plain Exception otherwise. GossipSamplePercent controls what fraction of cluster nodes are contacted per gossip round (configured via --gossip-sp / GossipSamplePercent option, default 100). Out-of-range values break the gossip sampling math, so construction is aborted before any cluster manager is created.
Source
Thrown at libs/cluster/Server/ClusterProvider.cs:62
/// <summary>
/// Create new cluster provider
/// </summary>
public ClusterProvider(StoreWrapper storeWrapper, RangeIndexManager rangeIndexManager)
{
this.storeWrapper = storeWrapper;
this.serverOptions = storeWrapper.serverOptions;
this.rangeIndexManager = rangeIndexManager;
this.loggerFactory = storeWrapper.loggerFactory;
authContainer = new ClusterAuthContainer
{
ClusterUsername = serverOptions.ClusterUsername,
ClusterPassword = serverOptions.ClusterPassword
};
if (serverOptions.GossipSamplePercent is > 100 or < 0)
{
throw new Exception("Gossip sample fraction should be in range [0,100]");
}
this.clusterManager = new ClusterManager(this, logger: loggerFactory?.CreateLogger("ClusterManager"));
this.replicationManager = new ReplicationManager(this, logger: loggerFactory?.CreateLogger("ReplicationManager"));
this.failoverManager = new FailoverManager(this, logger: loggerFactory?.CreateLogger("FailoverManager"));
this.migrationManager = new MigrationManager(this, logger: loggerFactory?.CreateLogger("MigrationManager"));
}
/// <inheritdoc />
public bool AllowDataLoss
=> serverOptions.AllowDataLoss;
/// <inheritdoc />
public ValueTask RecoverAsync()
=> replicationManager.RecoverAsync();
/// <inheritdoc />View on GitHub (pinned to 951b0fc683)
Solutions
- Set --gossip-sp (GossipSamplePercent) to an integer in [0,100]; the default 100 is valid.
- Validate the config value in your deployment script before launching the server.
- Check defaults.conf / configuration.md: the documented range is exactly [0,100].
Example fix
// before — invalid gossip sample percent in config "GossipSamplePercent" : 150, // after — within documented range "GossipSamplePercent" : 100,
Defensive patterns
Strategy: validation
Validate before calling
if (serverOptions.GossipSamplePercent is < 0 or > 100)
throw new ArgumentOutOfRangeException(nameof(serverOptions.GossipSamplePercent), "must be in [0,100]"); Type guard
bool IsValidGossipPercent(int v) => v is >= 0 and <= 100;
Prevention
- Set --gossip-sp / GossipSamplePercent to an integer in [0,100] (default 100).
- Validate the config value in deployment scripts before launch.
- Refer to configuration.md: documented range is exactly [0,100].
When it happens
Trigger: Starting a Garnet server in cluster mode with --gossip-sp set to a value below 0 or above 100 (e.g. a typo, a config file with 150, or a negative sentinel).
Common situations: Typo in defaults.conf/command line; a config templating bug injecting an invalid integer; copying a config across environments and forgetting to adjust the percentage; an env var parsed as the wrong type.
Related errors
- Cluster announce endpoint does not match list of listen endp
- Invalid ClusterConfig payload: too short to contain a versio
- Incompatible ClusterConfig version: expected {ClusterConfigV
- Cannot use AzureStorage device without supplying storage-str
- Cannot use AzureStorage device with both storage-string and
AI-assisted analysis of microsoft/garnet@951b0fc683 (2026-08-13).
Data as JSON: /api/errors/a8f35fe96956fb93.
Report an issue: GitHub.