From 477888f8c3d308e3ac8c1b993557c1b9d9774967 Mon Sep 17 00:00:00 2001 From: miaow999 Date: Thu, 1 Jun 2023 14:22:02 +0800 Subject: [PATCH] reset cache when get cache error (#575) Co-authored-by: miaodanyang --- plugin/cache/localcache/cache.go | 2 ++ service/node.go | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/plugin/cache/localcache/cache.go b/plugin/cache/localcache/cache.go index 543ccc08..d96976ab 100644 --- a/plugin/cache/localcache/cache.go +++ b/plugin/cache/localcache/cache.go @@ -3,6 +3,7 @@ package localcache import ( "github.com/VictoriaMetrics/fastcache" "github.com/baetyl/baetyl-go/v2/errors" + "github.com/baetyl/baetyl-go/v2/log" "github.com/baetyl/baetyl-cloud/v2/common" "github.com/baetyl/baetyl-cloud/v2/plugin" @@ -24,6 +25,7 @@ func New() (plugin.Plugin, error) { return nil, errors.Trace(err) } cache := fastcache.New(cfg.FastCacheConfig.MaxBytes) + log.L().Info("cache set maxBytesSize", log.Any("size", cfg.FastCacheConfig.MaxBytes)) return &localFastCache{ c: cache, }, nil diff --git a/service/node.go b/service/node.go index f07d9269..b1910587 100644 --- a/service/node.go +++ b/service/node.go @@ -387,7 +387,8 @@ func (n *NodeServiceImpl) GetAllShadowReportTime(namespace string, lenNode int) if dataReportTime != nil { err = json.Unmarshal(dataReportTime, &reportTimeMap) if err != nil { - return nil, errors.Trace(err) + log.L().Error("decode report time error", log.Error(err)) + return n.SetNodeShadowCache(namespace) } } // check time cache len < lenNode