From e70513e6711de9aedecc90a7dde99da33d67d7df Mon Sep 17 00:00:00 2001 From: lucasliang Date: Mon, 16 Oct 2023 12:02:43 +0800 Subject: [PATCH] bugfix: fix invalid nil pointer when trying to record Store.SlownessStat. (#1017) * bugfix: fix invalid nil pointer when trying to record Store.SlownessStat. Signed-off-by: lucasliang * Polish codes. Signed-off-by: lucasliang * Polish comments. Signed-off-by: lucasliang --------- Signed-off-by: lucasliang --- internal/locate/region_request.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/locate/region_request.go b/internal/locate/region_request.go index 7d2aaf82e..9c9e613e0 100644 --- a/internal/locate/region_request.go +++ b/internal/locate/region_request.go @@ -1679,8 +1679,8 @@ func (s *RegionRequestSender) sendReqToRegion( if !injectFailOnSend { start := time.Now() resp, err = s.client.SendRequest(ctx, sendToAddr, req, timeout) - // Record timecost of external requests on related Store when ReplicaReadMode == PreferLeader. - if req.ReplicaReadType == kv.ReplicaReadPreferLeader && !util.IsInternalRequest(req.RequestSource) { + // Record timecost of external requests on related Store when `ReplicaReadMode == "PreferLeader"`. + if rpcCtx.Store != nil && req.ReplicaReadType == kv.ReplicaReadPreferLeader && !util.IsInternalRequest(req.RequestSource) { rpcCtx.Store.recordSlowScoreStat(time.Since(start)) } if s.Stats != nil {