Skip to content
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 9 commits into from
Jun 25, 2018
19 changes: 10 additions & 9 deletions ddl/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add it?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Member

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?

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.
Copy link
Member

Choose a reason for hiding this comment

The 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) {
Expand Down