From 8364c7a2b8964fcfbf7e1800a6f1558cee868fb1 Mon Sep 17 00:00:00 2001 From: ti-srebot <66930949+ti-srebot@users.noreply.github.com> Date: Mon, 14 Dec 2020 19:43:38 +0800 Subject: [PATCH] cherry pick #636 to release-4.0 (#637) Signed-off-by: ti-srebot Co-authored-by: 3pointer --- pkg/restore/split.go | 2 +- pkg/restore/split_client.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/restore/split.go b/pkg/restore/split.go index e44d31f5a..73fcfd4f8 100644 --- a/pkg/restore/split.go +++ b/pkg/restore/split.go @@ -132,7 +132,7 @@ SplitRegions: } time.Sleep(interval) if i > 3 { - log.Warn("splitting regions failed, retry it", zap.Error(errSplit), zap.Array("keys", logutil.WrapKeys(keys))) + log.Warn("splitting regions failed, retry it", zap.Error(errSplit), zap.Any("region", region), zap.Array("keys", logutil.WrapKeys(keys))) } continue SplitRegions } diff --git a/pkg/restore/split_client.go b/pkg/restore/split_client.go index 1a24d49a2..9af0325ef 100755 --- a/pkg/restore/split_client.go +++ b/pkg/restore/split_client.go @@ -242,7 +242,9 @@ func (c *pdClient) sendSplitRegionRequest( var splitErrors error for i := 0; i < splitRegionMaxRetryTime; i++ { var peer *metapb.Peer - if regionInfo.Leader != nil { + // scanRegions may return empty Leader in https://github.com/tikv/pd/blob/v4.0.8/server/grpc_service.go#L524 + // so wee also need check Leader.Id != 0 + if regionInfo.Leader != nil && regionInfo.Leader.Id != 0 { peer = regionInfo.Leader } else { if len(regionInfo.Region.Peers) == 0 {