{"record":{"id":"a8f35fe96956fb93","repo":"microsoft/garnet","slug":"gossip-sample-fraction-should-be-in-range-0-100","errorCode":null,"errorMessage":"Gossip sample fraction should be in range [0,100]","messagePattern":"Gossip sample fraction should be in range \\[0,100\\]","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"libs/cluster/Server/ClusterProvider.cs","lineNumber":62,"sourceCode":"        /// <summary>\n        /// Create new cluster provider\n        /// </summary>\n        public ClusterProvider(StoreWrapper storeWrapper, RangeIndexManager rangeIndexManager)\n        {\n            this.storeWrapper = storeWrapper;\n            this.serverOptions = storeWrapper.serverOptions;\n            this.rangeIndexManager = rangeIndexManager;\n            this.loggerFactory = storeWrapper.loggerFactory;\n\n            authContainer = new ClusterAuthContainer\n            {\n                ClusterUsername = serverOptions.ClusterUsername,\n                ClusterPassword = serverOptions.ClusterPassword\n            };\n\n            if (serverOptions.GossipSamplePercent is > 100 or < 0)\n            {\n                throw new Exception(\"Gossip sample fraction should be in range [0,100]\");\n            }\n\n            this.clusterManager = new ClusterManager(this, logger: loggerFactory?.CreateLogger(\"ClusterManager\"));\n            this.replicationManager = new ReplicationManager(this, logger: loggerFactory?.CreateLogger(\"ReplicationManager\"));\n\n            this.failoverManager = new FailoverManager(this, logger: loggerFactory?.CreateLogger(\"FailoverManager\"));\n            this.migrationManager = new MigrationManager(this, logger: loggerFactory?.CreateLogger(\"MigrationManager\"));\n        }\n\n        /// <inheritdoc />\n        public bool AllowDataLoss\n            => serverOptions.AllowDataLoss;\n\n        /// <inheritdoc />\n        public ValueTask RecoverAsync()\n            => replicationManager.RecoverAsync();\n\n        /// <inheritdoc />","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/cluster/Server/ClusterProvider.cs#L44-L80","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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]."],"exampleFix":"// before — invalid gossip sample percent in config\n\"GossipSamplePercent\" : 150,\n\n// after — within documented range\n\"GossipSamplePercent\" : 100,","handlingStrategy":"validation","validationCode":"if (serverOptions.GossipSamplePercent is < 0 or > 100)\n    throw new ArgumentOutOfRangeException(nameof(serverOptions.GossipSamplePercent), \"must be in [0,100]\");","typeGuard":"bool IsValidGossipPercent(int v) => v is >= 0 and <= 100;","tryCatchPattern":null,"preventionTips":["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]."],"tags":["csharp","cluster","config","gossip","validation","startup"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}