From c500b871b9f21af0869745c7a50a22e264dd7094 Mon Sep 17 00:00:00 2001 From: Andriy Biletsky Date: Fri, 24 Jan 2025 23:11:30 +0700 Subject: [PATCH 1/2] Remove extra details in query cache keys --- app/query/cache.go | 4 ++-- app/query/processors.go | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/query/cache.go b/app/query/cache.go index 2e603a05..e7060623 100644 --- a/app/query/cache.go +++ b/app/query/cache.go @@ -84,10 +84,10 @@ func NewCacheRequest(method string, params any, metaKey string) CacheRequest { } } -func (c *QueryCache) Retrieve(query *Query, metaKey string, getter func() (any, error)) (*CachedResponse, error) { +func (c *QueryCache) Retrieve(query *Query, getter func() (any, error)) (*CachedResponse, error) { log := logger.Log() - cacheReq := NewCacheRequest(query.Method(), query.Params(), metaKey) + cacheReq := NewCacheRequest(query.Method(), query.Params(), "") ctx, cancel := context.WithTimeout(context.Background(), 5000*time.Millisecond) defer cancel() diff --git a/app/query/processors.go b/app/query/processors.go index 9adafc2f..556231f9 100644 --- a/app/query/processors.go +++ b/app/query/processors.go @@ -686,8 +686,7 @@ func preflightCacheHook(caller *Caller, ctx context.Context) (*jsonrpc.RPCRespon return resp, err } - metaKey := fmt.Sprintf("%d@%s", caller.userID, caller.Endpoint()) - cachedResp, err := caller.Cache.Retrieve(query, metaKey, getter) + cachedResp, err := caller.Cache.Retrieve(query, getter) if err != nil { return nil, rpcerrors.NewSDKError(err) } From 9eb16cc60312522caa29701e4f51282872eb6fa5 Mon Sep 17 00:00:00 2001 From: Andriy Biletsky Date: Fri, 24 Jan 2025 23:13:54 +0700 Subject: [PATCH 2/2] Add user details to retry logging --- app/query/processors.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/query/processors.go b/app/query/processors.go index 556231f9..550ce60f 100644 --- a/app/query/processors.go +++ b/app/query/processors.go @@ -663,8 +663,8 @@ func preflightCacheHook(caller *Caller, ctx context.Context) (*jsonrpc.RPCRespon case err == nil && resp.Error == nil: if attempt > 0 { log.Infof( - "cache retriever %s attempt #%d succeeded (after spending %.2f seconds)", - query.Method(), attempt, time.Since(totalStart).Seconds(), + "cache retriever %s attempt #%d succeeded (after spending %.2f seconds) for %d@%s", + query.Method(), attempt, time.Since(totalStart).Seconds(), caller.userID, caller.Endpoint(), ) QueryCacheRetrySuccesses.Observe(float64(attempt)) } @@ -672,14 +672,14 @@ func preflightCacheHook(caller *Caller, ctx context.Context) (*jsonrpc.RPCRespon case err != nil: QueryCacheRetrievalFailures.WithLabelValues(CacheRetrievalErrorNet, query.Method()).Inc() log.Infof( - "cache retriever %s attempt #%d failed after %.3fs, err=%+v @ %s", - query.Method(), attempt, duration, err, caller.Endpoint(), + "cache retriever %s attempt #%d failed after %.3fs, err=%+v for %d@%s", + query.Method(), attempt, duration, err, caller.userID, caller.Endpoint(), ) case resp.Error != nil: QueryCacheRetrievalFailures.WithLabelValues(CacheRetrievalErrorSdk, query.Method()).Inc() log.Infof( - "cache retriever %s attempt #%d failed after %.3fs, resp=%+v @ %s", - query.Method(), attempt, duration, resp.Error, caller.Endpoint(), + "cache retriever %s attempt #%d failed after %.3fs, resp=%+v @ %d@%s", + query.Method(), attempt, duration, resp.Error, caller.userID, caller.Endpoint(), ) } }