copr: avoid NPE when store is not available when balance batch cop task (#28110)

This commit is contained in:
xufei
2021-09-17 13:26:42 +08:00
committed by GitHub
parent 9b0604b375
commit c6dfd705e1

View File

@ -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()