Skip to content

Commit

Permalink
lightning: refresh leader+peer for not-leader error
Browse files Browse the repository at this point in the history
Signed-off-by: lance6716 <[email protected]>
  • Loading branch information
lance6716 committed Apr 15, 2023
1 parent bd3a036 commit 4f7271a
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions br/pkg/lightning/backend/local/region_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,18 +546,14 @@ func (j *regionJob) fixIngestError(
case errPb.NotLeader != nil:
j.lastRetryableErr = common.ErrKVNotLeader.GenWithStack(errPb.GetMessage())

if newLeader := errPb.GetNotLeader().GetLeader(); newLeader != nil {
newRegion = &split.RegionInfo{
Leader: newLeader,
Region: j.region.Region,
}
} else {
newRegion, err = getRegion()
if err != nil {
return false, errors.Trace(err)
}
// NotLeader error may mask the region epoch not match error. We refresh
// the region for bad case.
newRegion, err = getRegion()
if err != nil {
return false, errors.Trace(err)
}
j.region = newRegion
j.convertStageTo(regionScanned)
return true, nil
case errPb.EpochNotMatch != nil:
j.lastRetryableErr = common.ErrKVEpochNotMatch.GenWithStack(errPb.GetMessage())
Expand Down

0 comments on commit 4f7271a

Please sign in to comment.