From 9ac856a1009b1d0b4352a198fcf3ce9a0fceef78 Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Sat, 13 May 2023 02:07:07 +0800 Subject: [PATCH] config: disallow `ThrottlerConfig.MaxRecheckDelay` < 1 ms (#1435) --- config/config.go | 4 ++++ utils/constants/networking.go | 1 + 2 files changed, 5 insertions(+) diff --git a/config/config.go b/config/config.go index 83b46e400355..a4e71d370baf 100644 --- a/config/config.go +++ b/config/config.go @@ -433,6 +433,10 @@ func getNetworkConfig( return network.Config{}, fmt.Errorf("%q must be >= 0", OutboundConnectionTimeoutKey) case config.PeerListGossipFreq < 0: return network.Config{}, fmt.Errorf("%s must be >= 0", NetworkPeerListGossipFreqKey) + case config.ThrottlerConfig.InboundMsgThrottlerConfig.CPUThrottlerConfig.MaxRecheckDelay < constants.MinInboundThrottlerMaxRecheckDelay: + return network.Config{}, fmt.Errorf("%s must be >= %d", InboundThrottlerCPUMaxRecheckDelayKey, constants.MinInboundThrottlerMaxRecheckDelay) + case config.ThrottlerConfig.InboundMsgThrottlerConfig.DiskThrottlerConfig.MaxRecheckDelay < constants.MinInboundThrottlerMaxRecheckDelay: + return network.Config{}, fmt.Errorf("%s must be >= %d", InboundThrottlerDiskMaxRecheckDelayKey, constants.MinInboundThrottlerMaxRecheckDelay) case config.MaxReconnectDelay < 0: return network.Config{}, fmt.Errorf("%s must be >= 0", NetworkMaxReconnectDelayKey) case config.InitialReconnectDelay < 0: diff --git a/utils/constants/networking.go b/utils/constants/networking.go index 7290718c267a..61ce863c57ec 100644 --- a/utils/constants/networking.go +++ b/utils/constants/networking.go @@ -100,6 +100,7 @@ const ( DefaultInboundThrottlerBandwidthMaxBurstSize = DefaultMaxMessageSize DefaultInboundThrottlerCPUMaxRecheckDelay = 5 * time.Second DefaultInboundThrottlerDiskMaxRecheckDelay = 5 * time.Second + MinInboundThrottlerMaxRecheckDelay = time.Millisecond // Outbound Throttling DefaultOutboundThrottlerAtLargeAllocSize = 32 * units.MiB