From 6ff764f9fb1bfbff2625f46c732d3515b0443c70 Mon Sep 17 00:00:00 2001 From: Jorropo Date: Wed, 15 Mar 2023 04:40:16 +0100 Subject: [PATCH] fix: preserve Unlimited StreamsInbound in connmgr reconciliation Fixes #9695 --- core/node/libp2p/rcmgr.go | 4 ++++ core/node/libp2p/rcmgr_defaults.go | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/node/libp2p/rcmgr.go b/core/node/libp2p/rcmgr.go index 54bff2852df..3e162453102 100644 --- a/core/node/libp2p/rcmgr.go +++ b/core/node/libp2p/rcmgr.go @@ -459,6 +459,7 @@ func ensureConnMgrMakeSenseVsResourceMgr(concreteLimits rcmgr.ConcreteLimitConfi return fmt.Errorf(` Unable to initialize libp2p due to conflicting resource manager limit configuration. resource manager System.Conns (%d) must be bigger than ConnMgr.HighWater (%d) +See: https://github.com/ipfs/kubo/blob/master/docs/libp2p-resource-management.md#how-does-the-resource-manager-resourcemgr-relate-to-the-connection-manager-connmgr `, rcm.System.Conns, highWater) } if rcm.System.ConnsInbound != rcmgr.Unlimited && int64(rcm.System.ConnsInbound) <= highWater { @@ -466,6 +467,7 @@ resource manager System.Conns (%d) must be bigger than ConnMgr.HighWater (%d) return fmt.Errorf(` Unable to initialize libp2p due to conflicting resource manager limit configuration. resource manager System.ConnsInbound (%d) must be bigger than ConnMgr.HighWater (%d) +See: https://github.com/ipfs/kubo/blob/master/docs/libp2p-resource-management.md#how-does-the-resource-manager-resourcemgr-relate-to-the-connection-manager-connmgr `, rcm.System.ConnsInbound, highWater) } if rcm.System.Streams != rcmgr.Unlimited && int64(rcm.System.Streams) <= highWater { @@ -473,6 +475,7 @@ resource manager System.ConnsInbound (%d) must be bigger than ConnMgr.HighWater return fmt.Errorf(` Unable to initialize libp2p due to conflicting resource manager limit configuration. resource manager System.Streams (%d) must be bigger than ConnMgr.HighWater (%d) +See: https://github.com/ipfs/kubo/blob/master/docs/libp2p-resource-management.md#how-does-the-resource-manager-resourcemgr-relate-to-the-connection-manager-connmgr `, rcm.System.Streams, highWater) } if rcm.System.StreamsInbound != rcmgr.Unlimited && int64(rcm.System.StreamsInbound) <= highWater { @@ -480,6 +483,7 @@ resource manager System.Streams (%d) must be bigger than ConnMgr.HighWater (%d) return fmt.Errorf(` Unable to initialize libp2p due to conflicting resource manager limit configuration. resource manager System.StreamsInbound (%d) must be bigger than ConnMgr.HighWater (%d) +See: https://github.com/ipfs/kubo/blob/master/docs/libp2p-resource-management.md#how-does-the-resource-manager-resourcemgr-relate-to-the-connection-manager-connmgr `, rcm.System.StreamsInbound, highWater) } return nil diff --git a/core/node/libp2p/rcmgr_defaults.go b/core/node/libp2p/rcmgr_defaults.go index 5faaf7979b3..4f02c6b4a88 100644 --- a/core/node/libp2p/rcmgr_defaults.go +++ b/core/node/libp2p/rcmgr_defaults.go @@ -129,7 +129,9 @@ func createDefaultLimitConfig(cfg config.SwarmConfig) (limitConfig rcmgr.Concret } // Scale System.StreamsInbound as well, but use the existing ratio of StreamsInbound to ConnsInbound - partialLimits.System.StreamsInbound = rcmgr.LimitVal(maxInboundConns * int64(partialLimits.System.StreamsInbound) / int64(partialLimits.System.ConnsInbound)) + if partialLimits.System.StreamsInbound != rcmgr.Unlimited { + partialLimits.System.StreamsInbound = rcmgr.LimitVal(maxInboundConns * int64(partialLimits.System.StreamsInbound) / int64(partialLimits.System.ConnsInbound)) + } partialLimits.System.ConnsInbound = rcmgr.LimitVal(maxInboundConns) }