Skip to content

Commit

Permalink
store/copr: invalidate stale regions for Mpp query. (#24410) (#24432)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-srebot authored Jun 18, 2021
1 parent 65af991 commit 59e2f48
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions store/copr/mpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ func (m *mppIterator) handleDispatchReq(ctx context.Context, bo *tikv.Backoffer,
m.sendError(errors.New(realResp.Error.Msg))
return
}
for _, retry := range realResp.RetryRegions {
id := tikv.NewRegionVerID(retry.Id, retry.RegionEpoch.ConfVer, retry.RegionEpoch.Version)
logutil.BgLogger().Info("invalid region because tiflash detected stale region", zap.String("region id", id.String()))
m.store.GetRegionCache().InvalidateCachedRegionWithReason(id, tikv.EpochNotMatch)
}
failpoint.Inject("mppNonRootTaskError", func(val failpoint.Value) {
if val.(bool) && !req.IsRoot {
time.Sleep(1 * time.Second)
Expand Down
5 changes: 5 additions & 0 deletions store/tikv/region_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -1617,6 +1617,11 @@ type RegionVerID struct {
ver uint64
}

// NewRegionVerID creates a region ver id, which used for invalidating regions.
func NewRegionVerID(id, confVer, ver uint64) RegionVerID {
return RegionVerID{id, confVer, ver}
}

// GetID returns the id of the region
func (r *RegionVerID) GetID() uint64 {
return r.id
Expand Down

0 comments on commit 59e2f48

Please sign in to comment.