From b3f10ae5cc2a2059adfab43a958037a3f252c4a2 Mon Sep 17 00:00:00 2001 From: dragondriver Date: Thu, 12 Aug 2021 16:16:09 +0800 Subject: [PATCH] Fix 6990, enhance the log when parsing grpc recv/send parameters (#6993) Signed-off-by: dragondriver --- .../datacoord/client/paramtable.go | 37 ++++++++++++++++--- internal/distributed/datacoord/paramtable.go | 37 ++++++++++++++++--- .../distributed/datanode/client/paramtable.go | 37 ++++++++++++++++--- internal/distributed/datanode/param_table.go | 37 ++++++++++++++++--- .../indexcoord/client/paramtable.go | 37 ++++++++++++++++--- internal/distributed/indexcoord/paramtable.go | 37 ++++++++++++++++--- .../indexnode/client/paramtable.go | 37 ++++++++++++++++--- internal/distributed/indexnode/paramtable.go | 37 ++++++++++++++++--- .../distributed/proxy/client/paramtable.go | 37 ++++++++++++++++--- internal/distributed/proxy/paramtable.go | 37 ++++++++++++++++--- .../querycoord/client/paramtable.go | 37 ++++++++++++++++--- .../distributed/querycoord/param_table.go | 37 ++++++++++++++++--- .../querynode/client/paramtable.go | 37 ++++++++++++++++--- internal/distributed/querynode/param_table.go | 37 ++++++++++++++++--- .../rootcoord/client/paramtable.go | 37 ++++++++++++++++--- internal/distributed/rootcoord/param_table.go | 37 ++++++++++++++++--- internal/util/paramtable/basetable.go | 12 ------ internal/util/paramtable/basetable_test.go | 17 --------- 18 files changed, 496 insertions(+), 125 deletions(-) diff --git a/internal/distributed/datacoord/client/paramtable.go b/internal/distributed/datacoord/client/paramtable.go index b7a583fae9..b0ef063d24 100644 --- a/internal/distributed/datacoord/client/paramtable.go +++ b/internal/distributed/datacoord/client/paramtable.go @@ -12,6 +12,7 @@ package grpcdatacoordclient import ( + "strconv" "sync" "github.com/milvus-io/milvus/internal/distributed/grpcconfigs" @@ -42,22 +43,46 @@ func (pt *ParamTable) Init() { func (pt *ParamTable) initClientMaxSendSize() { var err error - pt.ClientMaxSendSize, err = pt.ParseIntWithErr("dataCoord.grpc.clientMaxSendSize") - if err != nil { + + valueStr, err := pt.Load("dataCoord.grpc.clientMaxSendSize") + if err != nil { // not set pt.ClientMaxSendSize = grpcconfigs.DefaultClientMaxSendSize - log.Debug("dataCoord.grpc.clientMaxSendSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse dataCoord.grpc.clientMaxSendSize, set to default", + zap.String("dataCoord.grpc.clientMaxSendSize", valueStr), + zap.Error(err)) + + pt.ClientMaxSendSize = grpcconfigs.DefaultClientMaxSendSize + } else { + pt.ClientMaxSendSize = value + } + log.Debug("initClientMaxSendSize", zap.Int("dataCoord.grpc.clientMaxSendSize", pt.ClientMaxSendSize)) } func (pt *ParamTable) initClientMaxRecvSize() { var err error - pt.ClientMaxRecvSize, err = pt.ParseIntWithErr("dataCoord.grpc.clientMaxRecvSize") - if err != nil { + + valueStr, err := pt.Load("dataCoord.grpc.clientMaxRecvSize") + if err != nil { // not set pt.ClientMaxRecvSize = grpcconfigs.DefaultClientMaxRecvSize - log.Debug("dataCoord.grpc.clientMaxRecvSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse dataCoord.grpc.clientMaxRecvSize, set to default", + zap.String("dataCoord.grpc.clientMaxRecvSize", valueStr), + zap.Error(err)) + + pt.ClientMaxRecvSize = grpcconfigs.DefaultClientMaxRecvSize + } else { + pt.ClientMaxRecvSize = value + } + log.Debug("initClientMaxRecvSize", zap.Int("dataCoord.grpc.clientMaxRecvSize", pt.ClientMaxRecvSize)) } diff --git a/internal/distributed/datacoord/paramtable.go b/internal/distributed/datacoord/paramtable.go index 6398f5301c..7b1d135ad9 100644 --- a/internal/distributed/datacoord/paramtable.go +++ b/internal/distributed/datacoord/paramtable.go @@ -12,6 +12,7 @@ package grpcdatacoordclient import ( + "strconv" "sync" "github.com/milvus-io/milvus/internal/distributed/grpcconfigs" @@ -78,22 +79,46 @@ func (pt *ParamTable) initDataCoordAddress() { func (pt *ParamTable) initServerMaxSendSize() { var err error - pt.ServerMaxSendSize, err = pt.ParseIntWithErr("dataCoord.grpc.serverMaxSendSize") - if err != nil { + + valueStr, err := pt.Load("dataCoord.grpc.serverMaxSendSize") + if err != nil { // not set pt.ServerMaxSendSize = grpcconfigs.DefaultServerMaxSendSize - log.Debug("dataCoord.grpc.serverMaxSendSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse dataCoord.grpc.serverMaxSendSize, set to default", + zap.String("dataCoord.grpc.serverMaxSendSize", valueStr), + zap.Error(err)) + + pt.ServerMaxSendSize = grpcconfigs.DefaultServerMaxSendSize + } else { + pt.ServerMaxSendSize = value + } + log.Debug("initServerMaxSendSize", zap.Int("dataCoord.grpc.serverMaxSendSize", pt.ServerMaxSendSize)) } func (pt *ParamTable) initServerMaxRecvSize() { var err error - pt.ServerMaxRecvSize, err = pt.ParseIntWithErr("dataCoord.grpc.serverMaxRecvSize") - if err != nil { + + valueStr, err := pt.Load("dataCoord.grpc.serverMaxRecvSize") + if err != nil { // not set pt.ServerMaxRecvSize = grpcconfigs.DefaultServerMaxRecvSize - log.Debug("dataCoord.grpc.serverMaxRecvSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse dataCoord.grpc.serverMaxRecvSize, set to default", + zap.String("dataCoord.grpc.serverMaxRecvSize", valueStr), + zap.Error(err)) + + pt.ServerMaxRecvSize = grpcconfigs.DefaultServerMaxRecvSize + } else { + pt.ServerMaxRecvSize = value + } + log.Debug("initServerMaxRecvSize", zap.Int("dataCoord.grpc.serverMaxRecvSize", pt.ServerMaxRecvSize)) } diff --git a/internal/distributed/datanode/client/paramtable.go b/internal/distributed/datanode/client/paramtable.go index 363ec16815..a1b6ea7486 100644 --- a/internal/distributed/datanode/client/paramtable.go +++ b/internal/distributed/datanode/client/paramtable.go @@ -12,6 +12,7 @@ package grpcdatanodeclient import ( + "strconv" "sync" "github.com/milvus-io/milvus/internal/distributed/grpcconfigs" @@ -42,22 +43,46 @@ func (pt *ParamTable) Init() { func (pt *ParamTable) initClientMaxSendSize() { var err error - pt.ClientMaxSendSize, err = pt.ParseIntWithErr("dataNode.grpc.clientMaxSendSize") - if err != nil { + + valueStr, err := pt.Load("dataNode.grpc.clientMaxSendSize") + if err != nil { // not set pt.ClientMaxSendSize = grpcconfigs.DefaultClientMaxSendSize - log.Debug("dataNode.grpc.clientMaxSendSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse dataNode.grpc.clientMaxSendSize, set to default", + zap.String("dataNode.grpc.clientMaxSendSize", valueStr), + zap.Error(err)) + + pt.ClientMaxSendSize = grpcconfigs.DefaultClientMaxSendSize + } else { + pt.ClientMaxSendSize = value + } + log.Debug("initClientMaxSendSize", zap.Int("dataNode.grpc.clientMaxSendSize", pt.ClientMaxSendSize)) } func (pt *ParamTable) initClientMaxRecvSize() { var err error - pt.ClientMaxRecvSize, err = pt.ParseIntWithErr("dataNode.grpc.clientMaxRecvSize") - if err != nil { + + valueStr, err := pt.Load("dataNode.grpc.clientMaxRecvSize") + if err != nil { // not set pt.ClientMaxRecvSize = grpcconfigs.DefaultClientMaxRecvSize - log.Debug("dataNode.grpc.clientMaxRecvSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse dataNode.grpc.clientMaxRecvSize, set to default", + zap.String("dataNode.grpc.clientMaxRecvSize", valueStr), + zap.Error(err)) + + pt.ClientMaxRecvSize = grpcconfigs.DefaultClientMaxRecvSize + } else { + pt.ClientMaxRecvSize = value + } + log.Debug("initClientMaxRecvSize", zap.Int("dataNode.grpc.clientMaxRecvSize", pt.ClientMaxRecvSize)) } diff --git a/internal/distributed/datanode/param_table.go b/internal/distributed/datanode/param_table.go index 6a036edf47..a25190de54 100644 --- a/internal/distributed/datanode/param_table.go +++ b/internal/distributed/datanode/param_table.go @@ -13,6 +13,7 @@ package grpcdatanode import ( "net" + "strconv" "sync" "github.com/milvus-io/milvus/internal/distributed/grpcconfigs" @@ -90,22 +91,46 @@ func (pt *ParamTable) initDataCoordAddress() { func (pt *ParamTable) initServerMaxSendSize() { var err error - pt.ServerMaxSendSize, err = pt.ParseIntWithErr("dataNode.grpc.serverMaxSendSize") - if err != nil { + + valueStr, err := pt.Load("dataNode.grpc.serverMaxSendSize") + if err != nil { // not set pt.ServerMaxSendSize = grpcconfigs.DefaultServerMaxSendSize - log.Debug("dataNode.grpc.serverMaxSendSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse dataNode.grpc.serverMaxSendSize, set to default", + zap.String("dataNode.grpc.serverMaxSendSize", valueStr), + zap.Error(err)) + + pt.ServerMaxSendSize = grpcconfigs.DefaultServerMaxSendSize + } else { + pt.ServerMaxSendSize = value + } + log.Debug("initServerMaxSendSize", zap.Int("dataNode.grpc.serverMaxSendSize", pt.ServerMaxSendSize)) } func (pt *ParamTable) initServerMaxRecvSize() { var err error - pt.ServerMaxRecvSize, err = pt.ParseIntWithErr("dataNode.grpc.serverMaxRecvSize") - if err != nil { + + valueStr, err := pt.Load("dataNode.grpc.serverMaxRecvSize") + if err != nil { // not set pt.ServerMaxRecvSize = grpcconfigs.DefaultServerMaxRecvSize - log.Debug("dataNode.grpc.serverMaxRecvSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse dataNode.grpc.serverMaxRecvSize, set to default", + zap.String("dataNode.grpc.serverMaxRecvSize", valueStr), + zap.Error(err)) + + pt.ServerMaxRecvSize = grpcconfigs.DefaultServerMaxRecvSize + } else { + pt.ServerMaxRecvSize = value + } + log.Debug("initServerMaxRecvSize", zap.Int("dataNode.grpc.serverMaxRecvSize", pt.ServerMaxRecvSize)) } diff --git a/internal/distributed/indexcoord/client/paramtable.go b/internal/distributed/indexcoord/client/paramtable.go index cfd3a73904..79f5686d0d 100644 --- a/internal/distributed/indexcoord/client/paramtable.go +++ b/internal/distributed/indexcoord/client/paramtable.go @@ -12,6 +12,7 @@ package grpcindexcoordclient import ( + "strconv" "sync" "github.com/milvus-io/milvus/internal/distributed/grpcconfigs" @@ -42,22 +43,46 @@ func (pt *ParamTable) Init() { func (pt *ParamTable) initClientMaxSendSize() { var err error - pt.ClientMaxSendSize, err = pt.ParseIntWithErr("indexCoord.grpc.clientMaxSendSize") - if err != nil { + + valueStr, err := pt.Load("indexCoord.grpc.clientMaxSendSize") + if err != nil { // not set pt.ClientMaxSendSize = grpcconfigs.DefaultClientMaxSendSize - log.Debug("indexCoord.grpc.clientMaxSendSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse indexCoord.grpc.clientMaxSendSize, set to default", + zap.String("indexCoord.grpc.clientMaxSendSize", valueStr), + zap.Error(err)) + + pt.ClientMaxSendSize = grpcconfigs.DefaultClientMaxSendSize + } else { + pt.ClientMaxSendSize = value + } + log.Debug("initClientMaxSendSize", zap.Int("indexCoord.grpc.clientMaxSendSize", pt.ClientMaxSendSize)) } func (pt *ParamTable) initClientMaxRecvSize() { var err error - pt.ClientMaxRecvSize, err = pt.ParseIntWithErr("indexCoord.grpc.clientMaxRecvSize") - if err != nil { + + valueStr, err := pt.Load("indexCoord.grpc.clientMaxRecvSize") + if err != nil { // not set pt.ClientMaxRecvSize = grpcconfigs.DefaultClientMaxRecvSize - log.Debug("indexCoord.grpc.clientMaxRecvSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse indexCoord.grpc.clientMaxRecvSize, set to default", + zap.String("indexCoord.grpc.clientMaxRecvSize", valueStr), + zap.Error(err)) + + pt.ClientMaxRecvSize = grpcconfigs.DefaultClientMaxRecvSize + } else { + pt.ClientMaxRecvSize = value + } + log.Debug("initClientMaxRecvSize", zap.Int("indexCoord.grpc.clientMaxRecvSize", pt.ClientMaxRecvSize)) } diff --git a/internal/distributed/indexcoord/paramtable.go b/internal/distributed/indexcoord/paramtable.go index fc8b58a27b..37557cfe39 100644 --- a/internal/distributed/indexcoord/paramtable.go +++ b/internal/distributed/indexcoord/paramtable.go @@ -12,6 +12,7 @@ package grpcindexcoord import ( + "strconv" "sync" "github.com/milvus-io/milvus/internal/distributed/grpcconfigs" @@ -63,22 +64,46 @@ func (pt *ParamTable) initServiceAddress() { func (pt *ParamTable) initServerMaxSendSize() { var err error - pt.ServerMaxSendSize, err = pt.ParseIntWithErr("indexCoord.grpc.serverMaxSendSize") - if err != nil { + + valueStr, err := pt.Load("indexCoord.grpc.serverMaxSendSize") + if err != nil { // not set pt.ServerMaxSendSize = grpcconfigs.DefaultServerMaxSendSize - log.Debug("indexCoord.grpc.serverMaxSendSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse indexCoord.grpc.serverMaxSendSize, set to default", + zap.String("indexCoord.grpc.serverMaxSendSize", valueStr), + zap.Error(err)) + + pt.ServerMaxSendSize = grpcconfigs.DefaultServerMaxSendSize + } else { + pt.ServerMaxSendSize = value + } + log.Debug("initServerMaxSendSize", zap.Int("indexCoord.grpc.serverMaxSendSize", pt.ServerMaxSendSize)) } func (pt *ParamTable) initServerMaxRecvSize() { var err error - pt.ServerMaxRecvSize, err = pt.ParseIntWithErr("indexCoord.grpc.serverMaxRecvSize") - if err != nil { + + valueStr, err := pt.Load("indexCoord.grpc.serverMaxRecvSize") + if err != nil { // not set pt.ServerMaxRecvSize = grpcconfigs.DefaultServerMaxRecvSize - log.Debug("indexCoord.grpc.serverMaxRecvSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse indexCoord.grpc.serverMaxRecvSize, set to default", + zap.String("indexCoord.grpc.serverMaxRecvSize", valueStr), + zap.Error(err)) + + pt.ServerMaxRecvSize = grpcconfigs.DefaultServerMaxRecvSize + } else { + pt.ServerMaxRecvSize = value + } + log.Debug("initServerMaxRecvSize", zap.Int("indexCoord.grpc.serverMaxRecvSize", pt.ServerMaxRecvSize)) } diff --git a/internal/distributed/indexnode/client/paramtable.go b/internal/distributed/indexnode/client/paramtable.go index d02691ffd5..45adfbd4e4 100644 --- a/internal/distributed/indexnode/client/paramtable.go +++ b/internal/distributed/indexnode/client/paramtable.go @@ -12,6 +12,7 @@ package grpcindexnodeclient import ( + "strconv" "sync" "github.com/milvus-io/milvus/internal/distributed/grpcconfigs" @@ -42,22 +43,46 @@ func (pt *ParamTable) Init() { func (pt *ParamTable) initClientMaxSendSize() { var err error - pt.ClientMaxSendSize, err = pt.ParseIntWithErr("indexNode.grpc.clientMaxSendSize") - if err != nil { + + valueStr, err := pt.Load("indexNode.grpc.clientMaxSendSize") + if err != nil { // not set pt.ClientMaxSendSize = grpcconfigs.DefaultClientMaxSendSize - log.Debug("indexNode.grpc.clientMaxSendSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse indexNode.grpc.clientMaxSendSize, set to default", + zap.String("indexNode.grpc.clientMaxSendSize", valueStr), + zap.Error(err)) + + pt.ClientMaxSendSize = grpcconfigs.DefaultClientMaxSendSize + } else { + pt.ClientMaxSendSize = value + } + log.Debug("initClientMaxSendSize", zap.Int("indexNode.grpc.clientMaxSendSize", pt.ClientMaxSendSize)) } func (pt *ParamTable) initClientMaxRecvSize() { var err error - pt.ClientMaxRecvSize, err = pt.ParseIntWithErr("indexNode.grpc.clientMaxRecvSize") - if err != nil { + + valueStr, err := pt.Load("indexNode.grpc.clientMaxRecvSize") + if err != nil { // not set pt.ClientMaxRecvSize = grpcconfigs.DefaultClientMaxRecvSize - log.Debug("indexNode.grpc.clientMaxRecvSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse indexNode.grpc.clientMaxRecvSize, set to default", + zap.String("indexNode.grpc.clientMaxRecvSize", valueStr), + zap.Error(err)) + + pt.ClientMaxRecvSize = grpcconfigs.DefaultClientMaxRecvSize + } else { + pt.ClientMaxRecvSize = value + } + log.Debug("initClientMaxRecvSize", zap.Int("indexNode.grpc.clientMaxRecvSize", pt.ClientMaxRecvSize)) } diff --git a/internal/distributed/indexnode/paramtable.go b/internal/distributed/indexnode/paramtable.go index f68b2fe1a4..ba0b5a84ea 100644 --- a/internal/distributed/indexnode/paramtable.go +++ b/internal/distributed/indexnode/paramtable.go @@ -12,6 +12,7 @@ package grpcindexnode import ( + "strconv" "sync" "github.com/milvus-io/milvus/internal/distributed/grpcconfigs" @@ -77,22 +78,46 @@ func (pt *ParamTable) initPort() { func (pt *ParamTable) initServerMaxSendSize() { var err error - pt.ServerMaxSendSize, err = pt.ParseIntWithErr("indexNode.grpc.serverMaxSendSize") - if err != nil { + + valueStr, err := pt.Load("indexNode.grpc.serverMaxSendSize") + if err != nil { // not set pt.ServerMaxSendSize = grpcconfigs.DefaultServerMaxSendSize - log.Debug("indexNode.grpc.serverMaxSendSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse indexNode.grpc.serverMaxSendSize, set to default", + zap.String("indexNode.grpc.serverMaxSendSize", valueStr), + zap.Error(err)) + + pt.ServerMaxSendSize = grpcconfigs.DefaultServerMaxSendSize + } else { + pt.ServerMaxSendSize = value + } + log.Debug("initServerMaxSendSize", zap.Int("indexNode.grpc.serverMaxSendSize", pt.ServerMaxSendSize)) } func (pt *ParamTable) initServerMaxRecvSize() { var err error - pt.ServerMaxRecvSize, err = pt.ParseIntWithErr("indexNode.grpc.serverMaxRecvSize") - if err != nil { + + valueStr, err := pt.Load("indexNode.grpc.serverMaxRecvSize") + if err != nil { // not set pt.ServerMaxRecvSize = grpcconfigs.DefaultServerMaxRecvSize - log.Debug("indexNode.grpc.serverMaxRecvSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse indexNode.grpc.serverMaxRecvSize, set to default", + zap.String("indexNode.grpc.serverMaxRecvSize", valueStr), + zap.Error(err)) + + pt.ServerMaxRecvSize = grpcconfigs.DefaultServerMaxRecvSize + } else { + pt.ServerMaxRecvSize = value + } + log.Debug("initServerMaxRecvSize", zap.Int("indexNode.grpc.serverMaxRecvSize", pt.ServerMaxRecvSize)) } diff --git a/internal/distributed/proxy/client/paramtable.go b/internal/distributed/proxy/client/paramtable.go index 1c89f1fded..12879ded73 100644 --- a/internal/distributed/proxy/client/paramtable.go +++ b/internal/distributed/proxy/client/paramtable.go @@ -12,6 +12,7 @@ package grpcproxyclient import ( + "strconv" "sync" "github.com/milvus-io/milvus/internal/distributed/grpcconfigs" @@ -42,22 +43,46 @@ func (pt *ParamTable) Init() { func (pt *ParamTable) initClientMaxSendSize() { var err error - pt.ClientMaxSendSize, err = pt.ParseIntWithErr("proxy.grpc.clientMaxSendSize") - if err != nil { + + valueStr, err := pt.Load("proxy.grpc.clientMaxSendSize") + if err != nil { // not set pt.ClientMaxSendSize = grpcconfigs.DefaultClientMaxSendSize - log.Debug("proxy.grpc.clientMaxSendSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse proxy.grpc.clientMaxSendSize, set to default", + zap.String("proxy.grpc.clientMaxSendSize", valueStr), + zap.Error(err)) + + pt.ClientMaxSendSize = grpcconfigs.DefaultClientMaxSendSize + } else { + pt.ClientMaxSendSize = value + } + log.Debug("initClientMaxSendSize", zap.Int("proxy.grpc.clientMaxSendSize", pt.ClientMaxSendSize)) } func (pt *ParamTable) initClientMaxRecvSize() { var err error - pt.ClientMaxRecvSize, err = pt.ParseIntWithErr("proxy.grpc.clientMaxRecvSize") - if err != nil { + + valueStr, err := pt.Load("proxy.grpc.clientMaxRecvSize") + if err != nil { // not set pt.ClientMaxRecvSize = grpcconfigs.DefaultClientMaxRecvSize - log.Debug("proxy.grpc.clientMaxRecvSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse proxy.grpc.clientMaxRecvSize, set to default", + zap.String("proxy.grpc.clientMaxRecvSize", valueStr), + zap.Error(err)) + + pt.ClientMaxRecvSize = grpcconfigs.DefaultClientMaxRecvSize + } else { + pt.ClientMaxRecvSize = value + } + log.Debug("initClientMaxRecvSize", zap.Int("proxy.grpc.clientMaxRecvSize", pt.ClientMaxRecvSize)) } diff --git a/internal/distributed/proxy/paramtable.go b/internal/distributed/proxy/paramtable.go index c9b7fc8b6c..1bbba70a2f 100644 --- a/internal/distributed/proxy/paramtable.go +++ b/internal/distributed/proxy/paramtable.go @@ -12,6 +12,7 @@ package grpcproxy import ( + "strconv" "sync" "github.com/milvus-io/milvus/internal/distributed/grpcconfigs" @@ -110,22 +111,46 @@ func (pt *ParamTable) initPort() { func (pt *ParamTable) initServerMaxSendSize() { var err error - pt.ServerMaxSendSize, err = pt.ParseIntWithErr("proxy.grpc.serverMaxSendSize") - if err != nil { + + valueStr, err := pt.Load("proxy.grpc.serverMaxSendSize") + if err != nil { // not set pt.ServerMaxSendSize = grpcconfigs.DefaultServerMaxSendSize - log.Debug("proxy.grpc.serverMaxSendSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse proxy.grpc.serverMaxSendSize, set to default", + zap.String("proxy.grpc.serverMaxSendSize", valueStr), + zap.Error(err)) + + pt.ServerMaxSendSize = grpcconfigs.DefaultServerMaxSendSize + } else { + pt.ServerMaxSendSize = value + } + log.Debug("initServerMaxSendSize", zap.Int("proxy.grpc.serverMaxSendSize", pt.ServerMaxSendSize)) } func (pt *ParamTable) initServerMaxRecvSize() { var err error - pt.ServerMaxRecvSize, err = pt.ParseIntWithErr("proxy.grpc.serverMaxRecvSize") - if err != nil { + + valueStr, err := pt.Load("proxy.grpc.serverMaxRecvSize") + if err != nil { // not set pt.ServerMaxRecvSize = grpcconfigs.DefaultServerMaxRecvSize - log.Debug("proxy.grpc.serverMaxRecvSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse proxy.grpc.serverMaxRecvSize, set to default", + zap.String("proxy.grpc.serverMaxRecvSize", valueStr), + zap.Error(err)) + + pt.ServerMaxRecvSize = grpcconfigs.DefaultServerMaxRecvSize + } else { + pt.ServerMaxRecvSize = value + } + log.Debug("initServerMaxRecvSize", zap.Int("proxy.grpc.serverMaxRecvSize", pt.ServerMaxRecvSize)) } diff --git a/internal/distributed/querycoord/client/paramtable.go b/internal/distributed/querycoord/client/paramtable.go index 4c6d3b052e..68422389a4 100644 --- a/internal/distributed/querycoord/client/paramtable.go +++ b/internal/distributed/querycoord/client/paramtable.go @@ -12,6 +12,7 @@ package grpcquerycoordclient import ( + "strconv" "sync" "github.com/milvus-io/milvus/internal/distributed/grpcconfigs" @@ -42,22 +43,46 @@ func (pt *ParamTable) Init() { func (pt *ParamTable) initClientMaxSendSize() { var err error - pt.ClientMaxSendSize, err = pt.ParseIntWithErr("queryCoord.grpc.clientMaxSendSize") - if err != nil { + + valueStr, err := pt.Load("queryCoord.grpc.clientMaxSendSize") + if err != nil { // not set pt.ClientMaxSendSize = grpcconfigs.DefaultClientMaxSendSize - log.Debug("queryCoord.grpc.clientMaxSendSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse queryCoord.grpc.clientMaxSendSize, set to default", + zap.String("queryCoord.grpc.clientMaxSendSize", valueStr), + zap.Error(err)) + + pt.ClientMaxSendSize = grpcconfigs.DefaultClientMaxSendSize + } else { + pt.ClientMaxSendSize = value + } + log.Debug("initClientMaxSendSize", zap.Int("queryCoord.grpc.clientMaxSendSize", pt.ClientMaxSendSize)) } func (pt *ParamTable) initClientMaxRecvSize() { var err error - pt.ClientMaxRecvSize, err = pt.ParseIntWithErr("queryCoord.grpc.clientMaxRecvSize") - if err != nil { + + valueStr, err := pt.Load("queryCoord.grpc.clientMaxRecvSize") + if err != nil { // not set pt.ClientMaxRecvSize = grpcconfigs.DefaultClientMaxRecvSize - log.Debug("queryCoord.grpc.clientMaxRecvSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse queryCoord.grpc.clientMaxRecvSize, set to default", + zap.String("queryCoord.grpc.clientMaxRecvSize", valueStr), + zap.Error(err)) + + pt.ClientMaxRecvSize = grpcconfigs.DefaultClientMaxRecvSize + } else { + pt.ClientMaxRecvSize = value + } + log.Debug("initClientMaxRecvSize", zap.Int("queryCoord.grpc.clientMaxRecvSize", pt.ClientMaxRecvSize)) } diff --git a/internal/distributed/querycoord/param_table.go b/internal/distributed/querycoord/param_table.go index e3016b710c..c34a703112 100644 --- a/internal/distributed/querycoord/param_table.go +++ b/internal/distributed/querycoord/param_table.go @@ -12,6 +12,7 @@ package grpcquerycoord import ( + "strconv" "sync" "github.com/milvus-io/milvus/internal/distributed/grpcconfigs" @@ -69,22 +70,46 @@ func (pt *ParamTable) initPort() { func (pt *ParamTable) initServerMaxSendSize() { var err error - pt.ServerMaxSendSize, err = pt.ParseIntWithErr("queryCoord.grpc.serverMaxSendSize") - if err != nil { + + valueStr, err := pt.Load("queryCoord.grpc.serverMaxSendSize") + if err != nil { // not set pt.ServerMaxSendSize = grpcconfigs.DefaultServerMaxSendSize - log.Debug("queryCoord.grpc.serverMaxSendSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse queryCoord.grpc.serverMaxSendSize, set to default", + zap.String("queryCoord.grpc.serverMaxSendSize", valueStr), + zap.Error(err)) + + pt.ServerMaxSendSize = grpcconfigs.DefaultServerMaxSendSize + } else { + pt.ServerMaxSendSize = value + } + log.Debug("initServerMaxSendSize", zap.Int("queryCoord.grpc.serverMaxSendSize", pt.ServerMaxSendSize)) } func (pt *ParamTable) initServerMaxRecvSize() { var err error - pt.ServerMaxRecvSize, err = pt.ParseIntWithErr("queryCoord.grpc.serverMaxRecvSize") - if err != nil { + + valueStr, err := pt.Load("queryCoord.grpc.serverMaxRecvSize") + if err != nil { // not set pt.ServerMaxRecvSize = grpcconfigs.DefaultServerMaxRecvSize - log.Debug("queryCoord.grpc.serverMaxRecvSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse queryCoord.grpc.serverMaxRecvSize, set to default", + zap.String("queryCoord.grpc.serverMaxRecvSize", valueStr), + zap.Error(err)) + + pt.ServerMaxRecvSize = grpcconfigs.DefaultServerMaxRecvSize + } else { + pt.ServerMaxRecvSize = value + } + log.Debug("initServerMaxRecvSize", zap.Int("queryCoord.grpc.serverMaxRecvSize", pt.ServerMaxRecvSize)) } diff --git a/internal/distributed/querynode/client/paramtable.go b/internal/distributed/querynode/client/paramtable.go index 934d9c5bb1..7a5f0184f2 100644 --- a/internal/distributed/querynode/client/paramtable.go +++ b/internal/distributed/querynode/client/paramtable.go @@ -12,6 +12,7 @@ package grpcquerynodeclient import ( + "strconv" "sync" "github.com/milvus-io/milvus/internal/distributed/grpcconfigs" @@ -42,22 +43,46 @@ func (pt *ParamTable) Init() { func (pt *ParamTable) initClientMaxSendSize() { var err error - pt.ClientMaxSendSize, err = pt.ParseIntWithErr("queryNode.grpc.clientMaxSendSize") - if err != nil { + + valueStr, err := pt.Load("queryNode.grpc.clientMaxSendSize") + if err != nil { // not set pt.ClientMaxSendSize = grpcconfigs.DefaultClientMaxSendSize - log.Debug("queryNode.grpc.clientMaxSendSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse queryNode.grpc.clientMaxSendSize, set to default", + zap.String("queryNode.grpc.clientMaxSendSize", valueStr), + zap.Error(err)) + + pt.ClientMaxSendSize = grpcconfigs.DefaultClientMaxSendSize + } else { + pt.ClientMaxSendSize = value + } + log.Debug("initClientMaxSendSize", zap.Int("queryNode.grpc.clientMaxSendSize", pt.ClientMaxSendSize)) } func (pt *ParamTable) initClientMaxRecvSize() { var err error - pt.ClientMaxRecvSize, err = pt.ParseIntWithErr("queryNode.grpc.clientMaxRecvSize") - if err != nil { + + valueStr, err := pt.Load("queryNode.grpc.clientMaxRecvSize") + if err != nil { // not set pt.ClientMaxRecvSize = grpcconfigs.DefaultClientMaxRecvSize - log.Debug("queryNode.grpc.clientMaxRecvSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse queryNode.grpc.clientMaxRecvSize, set to default", + zap.String("queryNode.grpc.clientMaxRecvSize", valueStr), + zap.Error(err)) + + pt.ClientMaxRecvSize = grpcconfigs.DefaultClientMaxRecvSize + } else { + pt.ClientMaxRecvSize = value + } + log.Debug("initClientMaxRecvSize", zap.Int("queryNode.grpc.clientMaxRecvSize", pt.ClientMaxRecvSize)) } diff --git a/internal/distributed/querynode/param_table.go b/internal/distributed/querynode/param_table.go index 96f29c7eac..4b76e6ef11 100644 --- a/internal/distributed/querynode/param_table.go +++ b/internal/distributed/querynode/param_table.go @@ -12,6 +12,7 @@ package grpcquerynode import ( + "strconv" "sync" "github.com/milvus-io/milvus/internal/distributed/grpcconfigs" @@ -102,22 +103,46 @@ func (pt *ParamTable) initPort() { func (pt *ParamTable) initServerMaxSendSize() { var err error - pt.ServerMaxSendSize, err = pt.ParseIntWithErr("queryNode.grpc.serverMaxSendSize") - if err != nil { + + valueStr, err := pt.Load("queryNode.grpc.serverMaxSendSize") + if err != nil { // not set pt.ServerMaxSendSize = grpcconfigs.DefaultServerMaxSendSize - log.Debug("queryNode.grpc.serverMaxSendSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse queryNode.grpc.serverMaxSendSize, set to default", + zap.String("queryNode.grpc.serverMaxSendSize", valueStr), + zap.Error(err)) + + pt.ServerMaxSendSize = grpcconfigs.DefaultServerMaxSendSize + } else { + pt.ServerMaxSendSize = value + } + log.Debug("initServerMaxSendSize", zap.Int("queryNode.grpc.serverMaxSendSize", pt.ServerMaxSendSize)) } func (pt *ParamTable) initServerMaxRecvSize() { var err error - pt.ServerMaxRecvSize, err = pt.ParseIntWithErr("queryNode.grpc.serverMaxRecvSize") - if err != nil { + + valueStr, err := pt.Load("queryNode.grpc.serverMaxRecvSize") + if err != nil { // not set pt.ServerMaxRecvSize = grpcconfigs.DefaultServerMaxRecvSize - log.Debug("queryNode.grpc.serverMaxRecvSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse queryNode.grpc.serverMaxRecvSize, set to default", + zap.String("queryNode.grpc.serverMaxRecvSize", valueStr), + zap.Error(err)) + + pt.ServerMaxRecvSize = grpcconfigs.DefaultServerMaxRecvSize + } else { + pt.ServerMaxRecvSize = value + } + log.Debug("initServerMaxRecvSize", zap.Int("queryNode.grpc.serverMaxRecvSize", pt.ServerMaxRecvSize)) } diff --git a/internal/distributed/rootcoord/client/paramtable.go b/internal/distributed/rootcoord/client/paramtable.go index 37cca30434..c01b05c6d0 100644 --- a/internal/distributed/rootcoord/client/paramtable.go +++ b/internal/distributed/rootcoord/client/paramtable.go @@ -12,6 +12,7 @@ package grpcrootcoordclient import ( + "strconv" "sync" "github.com/milvus-io/milvus/internal/distributed/grpcconfigs" @@ -42,22 +43,46 @@ func (pt *ParamTable) Init() { func (pt *ParamTable) initClientMaxSendSize() { var err error - pt.ClientMaxSendSize, err = pt.ParseIntWithErr("rootCoord.grpc.clientMaxSendSize") - if err != nil { + + valueStr, err := pt.Load("rootCoord.grpc.clientMaxSendSize") + if err != nil { // not set pt.ClientMaxSendSize = grpcconfigs.DefaultClientMaxSendSize - log.Debug("rootCoord.grpc.clientMaxSendSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse rootCoord.grpc.clientMaxSendSize, set to default", + zap.String("rootCoord.grpc.clientMaxSendSize", valueStr), + zap.Error(err)) + + pt.ClientMaxSendSize = grpcconfigs.DefaultClientMaxSendSize + } else { + pt.ClientMaxSendSize = value + } + log.Debug("initClientMaxSendSize", zap.Int("rootCoord.grpc.clientMaxSendSize", pt.ClientMaxSendSize)) } func (pt *ParamTable) initClientMaxRecvSize() { var err error - pt.ClientMaxRecvSize, err = pt.ParseIntWithErr("rootCoord.grpc.clientMaxRecvSize") - if err != nil { + + valueStr, err := pt.Load("rootCoord.grpc.clientMaxRecvSize") + if err != nil { // not set pt.ClientMaxRecvSize = grpcconfigs.DefaultClientMaxRecvSize - log.Debug("rootCoord.grpc.clientMaxRecvSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse rootCoord.grpc.clientMaxRecvSize, set to default", + zap.String("rootCoord.grpc.clientMaxRecvSize", valueStr), + zap.Error(err)) + + pt.ClientMaxRecvSize = grpcconfigs.DefaultClientMaxRecvSize + } else { + pt.ClientMaxRecvSize = value + } + log.Debug("initClientMaxRecvSize", zap.Int("rootCoord.grpc.clientMaxRecvSize", pt.ClientMaxRecvSize)) } diff --git a/internal/distributed/rootcoord/param_table.go b/internal/distributed/rootcoord/param_table.go index 69ad64d449..28629cc1f7 100644 --- a/internal/distributed/rootcoord/param_table.go +++ b/internal/distributed/rootcoord/param_table.go @@ -12,6 +12,7 @@ package grpcrootcoord import ( + "strconv" "sync" "github.com/milvus-io/milvus/internal/distributed/grpcconfigs" @@ -94,22 +95,46 @@ func (p *ParamTable) initDataCoordAddress() { func (p *ParamTable) initServerMaxSendSize() { var err error - p.ServerMaxSendSize, err = p.ParseIntWithErr("rootCoord.grpc.serverMaxSendSize") - if err != nil { + + valueStr, err := p.Load("rootCoord.grpc.serverMaxSendSize") + if err != nil { // not set p.ServerMaxSendSize = grpcconfigs.DefaultServerMaxSendSize - log.Debug("rootCoord.grpc.serverMaxSendSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse rootCoord.grpc.serverMaxSendSize, set to default", + zap.String("rootCoord.grpc.serverMaxSendSize", valueStr), + zap.Error(err)) + + p.ServerMaxSendSize = grpcconfigs.DefaultServerMaxSendSize + } else { + p.ServerMaxSendSize = value + } + log.Debug("initServerMaxSendSize", zap.Int("rootCoord.grpc.serverMaxSendSize", p.ServerMaxSendSize)) } func (p *ParamTable) initServerMaxRecvSize() { var err error - p.ServerMaxRecvSize, err = p.ParseIntWithErr("rootCoord.grpc.serverMaxRecvSize") - if err != nil { + + valueStr, err := p.Load("rootCoord.grpc.serverMaxRecvSize") + if err != nil { // not set p.ServerMaxRecvSize = grpcconfigs.DefaultServerMaxRecvSize - log.Debug("rootCoord.grpc.serverMaxRecvSize not set, set to default") } + + value, err := strconv.Atoi(valueStr) + if err != nil { // not in valid format + log.Warn("Failed to parse rootCoord.grpc.serverMaxRecvSize, set to default", + zap.String("rootCoord.grpc.serverMaxRecvSize", valueStr), + zap.Error(err)) + + p.ServerMaxRecvSize = grpcconfigs.DefaultServerMaxRecvSize + } else { + p.ServerMaxRecvSize = value + } + log.Debug("initServerMaxRecvSize", zap.Int("rootCoord.grpc.serverMaxRecvSize", p.ServerMaxRecvSize)) } diff --git a/internal/util/paramtable/basetable.go b/internal/util/paramtable/basetable.go index 61990d7992..7c55af6fab 100644 --- a/internal/util/paramtable/basetable.go +++ b/internal/util/paramtable/basetable.go @@ -316,18 +316,6 @@ func (gp *BaseTable) ParseInt(key string) int { return value } -func (gp *BaseTable) ParseIntWithErr(key string) (int, error) { - valueStr, err := gp.Load(key) - if err != nil { - return 0, err - } - value, err := strconv.Atoi(valueStr) - if err != nil { - return 0, err - } - return value, nil -} - // package methods func ConvertRangeToIntRange(rangeStr, sep string) []int { diff --git a/internal/util/paramtable/basetable_test.go b/internal/util/paramtable/basetable_test.go index 8e53169537..25f067a783 100644 --- a/internal/util/paramtable/basetable_test.go +++ b/internal/util/paramtable/basetable_test.go @@ -111,20 +111,3 @@ func TestGlobalParamsTable_LoadYaml(t *testing.T) { _, err = baseParams.Load("pulsar.port") assert.Nil(t, err) } - -func TestBaseTable_ParseIntWithErr(t *testing.T) { - var err error - - key1 := "ParseIntWithErrInt" - err = baseParams.Save(key1, "10") - assert.Nil(t, err) - ten, err := baseParams.ParseIntWithErr(key1) - assert.Nil(t, err) - assert.Equal(t, 10, ten) - - key2 := "ParseIntWithErrInvalidInt" - err = baseParams.Save(key2, "invalid") - assert.Nil(t, err) - _, err = baseParams.ParseIntWithErr(key2) - assert.NotNil(t, err) -}