From 50c26c113a9e26984114e12922f247ad4d4621a5 Mon Sep 17 00:00:00 2001 From: ti-srebot <66930949+ti-srebot@users.noreply.github.com> Date: Fri, 17 Dec 2021 18:30:38 +0800 Subject: [PATCH] copr: avoid NPE when store is not available when balance batch cop task (#28110) (#28138) --- store/copr/batch_coprocessor.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/store/copr/batch_coprocessor.go b/store/copr/batch_coprocessor.go index eb01ebbbbdaa6..8b8b02af407ee 100644 --- a/store/copr/batch_coprocessor.go +++ b/store/copr/batch_coprocessor.go @@ -155,7 +155,11 @@ func balanceBatchCopTask(ctx context.Context, kvStore *tikv.KVStore, originalTas }, 2*time.Second) if err != nil || !resp.Resp.(*mpp.IsAliveResponse).Available { - logutil.BgLogger().Warn("Cannot detect store's availability", zap.String("store address", s.GetAddr()), zap.String("err message", err.Error())) + errMsg := "store not ready to serve" + if err != nil { + errMsg = err.Error() + } + logutil.BgLogger().Warn("Store is not ready", zap.String("store address", s.GetAddr()), zap.String("err message", errMsg)) mu.Lock() mppStoreLastFailTime[s.GetAddr()] = time.Now() mu.Unlock()