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: reduce the interval for checking "create table/schema" #7608

Merged
merged 7 commits into from
Sep 12, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@ func checkJobMaxInterval(job *model.Job) time.Duration {
if job.Type == model.ActionAddIndex {
return 3 * time.Second
}
if job.Type == model.ActionCreateTable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a TODO here.

Copy link
Member

Choose a reason for hiding this comment

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

Why not consider CreateDatabase/DropTable....?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shenli
"DropTable" has 4 states. So this operation takes longer than it takes.

Copy link
Contributor

@zhexuany zhexuany Sep 6, 2018

Choose a reason for hiding this comment

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

I am confused by the context. Anyone help me out?

request add a TODO.

TODO for what?

Why not consider CreateDatabase/DropTable....?

you mean we reduce tick of CreateDatabase/DropTable to 500ms?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, they are the same story with CreateTable.

you mean we reduce tick of CreateDatabase/DropTable to 500ms?

Copy link
Member

Choose a reason for hiding this comment

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

@zimulala How long does it usually take to drop table/database?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shenli
This is the estimated time.

tidb> create database db;
Query OK, 0 rows affected (0.16 sec)
tidb> create table db.x(a int, b int);
Query OK, 0 rows affected (0.19 sec)
tidb> drop table db.x;
Query OK, 0 rows affected (0.39 sec)
tidb> drop database db;
Query OK, 0 rows affected (0.35 sec)

Copy link
Contributor

@winkyao winkyao Sep 6, 2018

Choose a reason for hiding this comment

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

@zhexuany We will use etcd to notify the job is done in the future, therefore we needn't wait an uncertain time here.

return 500 * time.Millisecond
}
return 1 * time.Second
}

Expand Down Expand Up @@ -484,7 +487,7 @@ func (d *ddl) doDDLJob(ctx sessionctx.Context, job *model.Job) error {
jobID := job.ID
// For a job from start to end, the state of it will be none -> delete only -> write only -> reorganization -> public
// For every state changes, we will wait as lease 2 * lease time, so here the ticker check is 10 * lease.
// But we use etcd to speed up, normally it takes less than 1s now, so we use 1s or 3s as the max value.
// But we use etcd to speed up, normally it takes less than 0.5s now, so we use 0.5s or 1s or 3s as the max value.
ticker := time.NewTicker(chooseLeaseTime(10*d.lease, checkJobMaxInterval(job)))
startTime := time.Now()
metrics.JobsGauge.WithLabelValues(job.Type.String()).Inc()
Expand Down