-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
ddl: speed up the operation of "create table" #6861
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9852c0d
ddl: update create table
zimulala 1c73a79
Merge branch 'master' into zimuxia/create-table
zimulala 0c942f9
ddl: clean up
zimulala 0a34f49
ddl: address comments
zimulala 68f8fa4
Merge branch 'master' into create-table
shenli 618dfe0
Merge branch 'master' into create-table
coocood a6e2cd3
Merge branch 'master' into create-table
zimulala 44e9e03
Merge branch 'master' into create-table
zz-jason c21d0c6
Merge branch 'master' into create-table
coocood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,11 +58,8 @@ func onCreateTable(d *ddlCtx, t *meta.Meta, job *model.Job) (ver int64, _ error) | |
return ver, errors.Trace(err) | ||
} | ||
if EnableSplitTableRegion { | ||
err = splitTableRegion(d.store, tbInfo.ID) | ||
// It will be automatically splitting by TiKV later. | ||
if err != nil { | ||
log.Warnf("[ddl] split table region failed %v", err) | ||
} | ||
// TODO: Add restrictions to this operation. | ||
go splitTableRegion(d.store, tbInfo.ID) | ||
} | ||
// Finish this job. | ||
job.FinishTableJob(model.JobStateDone, model.StatePublic, ver, tbInfo) | ||
|
@@ -130,19 +127,23 @@ func onDropTable(t *meta.Meta, job *model.Job) (ver int64, _ error) { | |
return ver, errors.Trace(err) | ||
} | ||
|
||
func splitTableRegion(store kv.Storage, tableID int64) error { | ||
type splitableStore interface { | ||
SplitRegion(splitKey kv.Key) error | ||
} | ||
|
||
func splitTableRegion(store kv.Storage, tableID int64) { | ||
type splitableStore interface { | ||
SplitRegion(splitKey kv.Key) error | ||
} | ||
s, ok := store.(splitableStore) | ||
if !ok { | ||
return nil | ||
return | ||
} | ||
tableStartKey := tablecodec.GenTablePrefix(tableID) | ||
if err := s.SplitRegion(tableStartKey); err != nil { | ||
return errors.Trace(err) | ||
// It will be automatically splitting by TiKV later. | ||
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. s/splitting/splited/ |
||
log.Warnf("[ddl] splitting table region failed %v", errors.ErrorStack(err)) | ||
} | ||
return nil | ||
} | ||
|
||
func getTable(store kv.Storage, schemaID int64, tblInfo *model.TableInfo) (table.Table, error) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why add it?
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.
I don't add it, I only move it from
splitTableRegion
to 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.
But it still appears in
splitTableRegion
.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.
Should we remove the code at line 135~137?