From ff93613a3519f1abb9810aaef406fdc99d43033a Mon Sep 17 00:00:00 2001 From: David Lutterkort Date: Wed, 25 Aug 2021 15:26:10 -0700 Subject: [PATCH] node: check that at least one replica for each shard has a non-zero weight --- node/src/config.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/node/src/config.rs b/node/src/config.rs index 757b3d41b46..02ecdd9e5b5 100644 --- a/node/src/config.rs +++ b/node/src/config.rs @@ -231,6 +231,16 @@ impl Shard { validate_name(name).context("illegal replica name")?; replica.validate(&self.pool_size)?; } + + let no_weight = + self.weight == 0 && self.replicas.values().all(|replica| replica.weight == 0); + if no_weight { + return Err(anyhow!( + "all weights for shard `{}` are 0; \ + remove explicit weights or set at least one of them to a value bigger than 0", + name + )); + } Ok(()) }