From c6dfd705e11a6fa44987f570775de0119fa6e48e Mon Sep 17 00:00:00 2001 From: xufei Date: Fri, 17 Sep 2021 13:26:42 +0800 Subject: [PATCH] copr: avoid NPE when store is not available when balance batch cop task (#28110) --- 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 a6587982ce..b00bfa738f 100644 --- a/store/copr/batch_coprocessor.go +++ b/store/copr/batch_coprocessor.go @@ -159,7 +159,11 @@ func balanceBatchCopTask(ctx context.Context, kvStore *kvStore, originalTasks [] }, 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()