-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*: support a region divided into multiple regions #11739
Changes from 10 commits
8005c6e
211ea04
d2fb615
cfb0522
f2beb31
efbbcab
c0420c1
d187883
6c95cf8
2c1f07b
ba9fa15
fde2a7c
dac8d5e
6c38a18
883d004
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,6 @@ import ( | |
|
||
"github.com/cznic/mathutil" | ||
"github.com/pingcap/errors" | ||
"github.com/pingcap/failpoint" | ||
"github.com/pingcap/kvproto/pkg/metapb" | ||
"github.com/pingcap/parser/model" | ||
"github.com/pingcap/parser/mysql" | ||
|
@@ -94,27 +93,18 @@ func (e *SplitIndexRegionExec) splitIndexRegion(ctx context.Context) error { | |
start := time.Now() | ||
ctxWithTimeout, cancel := context.WithTimeout(ctx, e.ctx.GetSessionVars().GetSplitRegionTimeout()) | ||
defer cancel() | ||
regionIDs := make([]uint64, 0, len(splitIdxKeys)) | ||
for _, idxKey := range splitIdxKeys { | ||
if isCtxDone(ctxWithTimeout) { | ||
break | ||
} | ||
|
||
regionID, err := s.SplitRegion(idxKey, true) | ||
if err != nil { | ||
logutil.BgLogger().Warn("split table index region failed", | ||
zap.String("table", e.tableInfo.Name.L), | ||
zap.String("index", e.indexInfo.Name.L), | ||
zap.Error(err)) | ||
continue | ||
} | ||
if regionID == 0 { | ||
continue | ||
} | ||
regionIDs = append(regionIDs, regionID) | ||
|
||
regionIDs, err := s.SplitRegions(context.Background(), splitIdxKeys, true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original code hasn't and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, never mind |
||
if err != nil { | ||
logutil.BgLogger().Warn("split table index region failed", | ||
zap.String("table", e.tableInfo.Name.L), | ||
zap.String("index", e.indexInfo.Name.L), | ||
zap.Error(err)) | ||
} | ||
e.splitRegions = len(regionIDs) | ||
if e.splitRegions == 0 { | ||
return nil | ||
} | ||
|
||
if !e.ctx.GetSessionVars().WaitSplitRegionFinish { | ||
return nil | ||
} | ||
|
@@ -294,30 +284,17 @@ func (e *SplitTableRegionExec) splitTableRegion(ctx context.Context) error { | |
if err != nil { | ||
return err | ||
} | ||
regionIDs := make([]uint64, 0, len(splitKeys)) | ||
for _, key := range splitKeys { | ||
failpoint.Inject("mockSplitRegionTimeout", func(val failpoint.Value) { | ||
if val.(bool) { | ||
time.Sleep(time.Second*1 + time.Millisecond*10) | ||
} | ||
}) | ||
if isCtxDone(ctxWithTimeout) { | ||
break | ||
} | ||
regionID, err := s.SplitRegion(key, true) | ||
if err != nil { | ||
logutil.BgLogger().Warn("split table region failed", | ||
zap.String("table", e.tableInfo.Name.L), | ||
zap.Error(err)) | ||
continue | ||
} | ||
if regionID == 0 { | ||
continue | ||
} | ||
regionIDs = append(regionIDs, regionID) | ||
|
||
regionIDs, err := s.SplitRegions(ctxWithTimeout, splitKeys, true) | ||
if err != nil { | ||
logutil.BgLogger().Warn("split table region failed", | ||
zap.String("table", e.tableInfo.Name.L), | ||
zap.Error(err)) | ||
} | ||
e.splitRegions = len(regionIDs) | ||
if e.splitRegions == 0 { | ||
return nil | ||
} | ||
|
||
if !e.ctx.GetSessionVars().WaitSplitRegionFinish { | ||
return nil | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we return an error here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the original code and several functions on the upper layer also did not return an error message.